I have a test suite/file that I have disabled. It has an associated snapshot file. For my particular situation I do not want to delete or update the snapshot file (long-story-short: it is used elsewhere).
So, Jest logs out just a warning, rather than a failure, for the obsolete snapshot. However Jest then exits with code 1 and my build fails. This happens despite no test actually failing.
Can I tweek the config to ignore obsolete snapshots? Or is there some other way to have Jest exit with code 0 after only a warning?
"Obsolete" refers to snapshots or snapshot files, for which no . toMatchSnapshot() exists any more. Snapshots are organised in one file per test suite. Single snapshots in those files are stored along with the name of their test, given in jest's it() function.
--forceExit Force Jest to exit after all tests have completed running. This is useful when resources set up by test code cannot be adequately cleaned up. This feature is an escape-hatch.
Jest has been rewritten with performance in mind, and snapshot testing is not an exception. Since snapshots are stored within text files, this way of testing is fast and reliable. Jest generates a new file for each test file that invokes the toMatchSnapshot matcher.
Jest is a popular framework for testing JavaScript, and Jest snapshot is a method for creating an HTML entity map for regression tests. Ideally, a developer can create a jest snapshot for each output\component and create a test that easily compares it in each run. If any change is detected, the test fails.
Add --silent to your test-ui script in the projects package.json
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