-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Jest -u -t deletes all other snapshot files #8375
Comments
This worked correctly for me when trying this with a minimal Jest setup - the snapshot in the focused test case is updated, the other one in the same snapshot file and the other one in a different snapshot file remain unchanged. Please provide a repro so we can reopen and see if other things might be involved in your case. |
Thanks @jeysal for reviewing. Found out that this is happening when expect has been extended to use toMatchSnapshot, as per documentation at https://jestjs.io/docs/en/expect#expectextendmatchers To reproduce: https://github.com/GSynergy/Snapshot-Bug |
Thanks, this reproduces for me now. I've updated the OP with the additional info. |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
🐛 Bug Report
Edit: Only happens when defining custom snapshot matchers such as
toMatchTrimmedSnapshot
from the docs.As listed in documentation, I tried to use jest -u -t to only run and update the snapshot of a particular test. It did run and updated the snapshot for that test, however, all snapshot files for other (skipped) tests were deleted. Please see log below:
PASS tests/pattern.spec.js (7.224s)
Snapshot Summary
› 6 snapshot files removed from 6 test suites.
Test Suites: 10 skipped, 1 passed, 1 of 11 total
Tests: 72 skipped, 1 passed, 73 total
Snapshots: 6 files removed, 1 passed, 1 total
Time: 10.072s
Ran all test suites with tests matching "pattern.*".
To Reproduce
Steps to reproduce the behavior:
Expected behavior
Snapshot of the test(s) matching the pattern should be updated. All other snapshots should remain intact
Link to repl or repo (highly encouraged)
https://github.com/GSynergy/Snapshot-Bug
Run
npx envinfo --preset jest
Paste the results here:
The text was updated successfully, but these errors were encountered: