How to update snapshot with Jest and vue-cli

Nikolay Dyankov picture Nikolay Dyankov · May 3, 2019 · Viewed 24.8k times · Source

I should be able to add -u parameter when running my tests, but I can't figure out why it doesn't work:

npm run test ComponentName.spec.js -u
npm run test ComponentName.spec.js --updateSnapshot

but it doesn't work. My package.json:

"scripts": {
    "test": "vue-cli-service test:unit",

I know I can just delete the snapshot files, but I'd like to figure out why the command doesn't work.

Answer

echo picture echo · May 13, 2019

based on the doc: https://jestjs.io/docs/en/cli#using-with-npm-scripts

npm run test -- -u

I verified this works.