javascriptreactjsjestjs

react jest confirming snapshot change


I am newbie at React and I can not find a solution for a simple problem. I am using create-react-app and I succeed to operate jest snapshot test. Then, for trying I changed render() function's inside. Now jest said me × has a valid snapshot (5ms) (I know it is normal.) and it says me:

1 snapshot test failed in 1 test suite. Inspect your code changes or press u to update them.

I don't know how can I update it. I tried to pressing u, ctrl + u and other combinations. But nothing changed in there. I know it is silly question but How can I update them?


Solution

  • you can update the snapshots in two ways:

    1. run npm test and then in the interactive shell press u

    2. run npm test -u, the -u flag tells jest to update snapshots.

    You could change npm by yarn if you are using yarn