I'm trying to figure out how o update a single snapshot file. In the docs it says just add the -t and I presume the file name but thats not working for me.
Example, in terminal I use.
jest -u -t test/js/tests/components/myTestApp.test.js
Any ideas why this would not work. I also added it as a string.
In order to run a specific test, you'll need to use the jest command. npm test will not work. To access jest directly on the command line, install it via npm i -g jest-cli or yarn global add jest-cli . Then simply run your specific test with jest bar.
Snapshot tests are useful when you want to make sure your UI does not change unexpectedly. A typical snapshot test case renders a UI component, takes a snapshot, then compares it to a reference snapshot file stored alongside the test.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With