Thanks for the great feature, and for Jest, both are very useful.
I'm running into an issue updating existing and cleaning up obsolete snapshots.
I have a component:
class Text extends React.Component {
render(){
return <div>hello world</div>
}
}
and a test:
const tree = renderer.create(<Text />).toJSON()
expect(tree).toMatchSnapshot()
The test successfully creates the snapshot in __tests__/__snapshots__.
When I change the div to <div>hello world 2</div>, I get an error as expected.
I run jest -u, and the snapshot remains, and continues to fail 1 snapshot test failed in 1 test file. Inspect your code changes or re-run with-uto update them.. I run a few more times, still not updating. Updating the snapshot manually fixes.
this is interesting... the only thing i can think of is that arguments don't get parsed.
do you have any code on github with this example so we can reproduce it?
otherwise you can stick console.log(newConfig) into this line and see if it prints the configuration correctly (it should have newConfig.updateSnapshot set to true when running with -u)
It turns out I had an older version of jest-cli installed globally. It was failing to use the argv parsing for jest in the project @ 14.0.0. npm uninstall jest-cli -g && npm i jest-cli -g seems to have fixed it. Thanks
@cpojer don't we use the local version of jest when running jest globally?
I worked around this by interactively updating the snapshot, not sure if it's a replicable case but for this time it worked.
Most helpful comment
It turns out I had an older version of jest-cli installed globally. It was failing to use the argv parsing for jest in the project @ 14.0.0.
npm uninstall jest-cli -g && npm i jest-cli -gseems to have fixed it. Thanks