jest updateSnapshot for specific test file

this works

jest /path/to/file --updateSnapshot

According to doc https://facebook.github.io/jest/docs/en/cli.html -t option is searching not for file name, but for specific spec name. They provided an example

jest -u -t="ColorPicker"

where "ColorPicker" is name of the spec, given in describe or test blocks.


If you run Jest via npm test, you can use arguments by inserting a -- between npm test and the Jest arguments - path & snapshot flag:

npm test -- path/to/file -u


In order to update particular snapshot, you can pass name as an argument to your script test command.

In package.json

"test": "jest --verbose"

In command line

npm test "<spec name>" -- -u

OR

npm test "<spec name>" -- --updateSnapshot

Tags:

Reactjs

Jestjs