[jest-snapshot] Custom Snapshot Directories confuse the Obsolete Snapshot Logger
See original GitHub issueš Bug Report
When using the new snapshot resolver feature: https://github.com/facebook/jest/pull/6143, the āObsoleteā Snapshot checker is deciding that all my snapshots are obsolete after a test run.
To Reproduce
- Using a simple project, configure a snapshot resolver to move your snapshot files to a different directory-structure.
- Run
yarn test
notice all your tests pass, and snapshots are in their new location - Notice that it says
45 snapshot files obsolete from 45 test suites.
- Run
jest -u
to remove obsolete snapshots, notice that all your snapshots are gone.
Expected behavior
I would expect that the snapshot files that just got written to wouldnāt be considered instantly obsolete.
Speculation: It looks like the custom snapshotResolver isnāt invoked when analyzing obsolete snapshots, so Jest doesnāt know that these files were actually written to, or something else is weird.
Link to repl or repo (highly encouraged)
I havenāt yet figured out how to do Snapshot Testing in repl.it, will upload a repo shortly if I canāt find an example.
Run npx envinfo --preset jest
Paste the results here:
System:
OS: macOS High Sierra 10.13.6
CPU: x64 Intel(R) Core(TM) i7-6820HQ CPU @ 2.70GHz
Binaries:
Node: 10.10.0 - /usr/local/bin/node
Yarn: 1.9.4 - /usr/local/bin/yarn
npm: 6.0.0 - /usr/local/bin/npm
npmPackages:
@types/jest: 23.x => 23.3.7
jest: ^24.0.0-alpha.1 => 24.0.0-alpha.1
Issue Analytics
- State:
- Created 5 years ago
- Comments:12 (1 by maintainers)
Top Results From Across the Web
What are obsolete snapshots and snapshot files?
It's been a while I posted this question and by know I can answer it myself: "Obsolete" refers to snapshots or snapshot files,Ā ......
Read more >Snapshot Testing
Snapshot tests are a very useful tool whenever you want to make sure your UI does not change unexpectedly.
Read more >React Snapshot Testing With Jest: An Introduction With ...
It's a technique for testing React components. Snapshot testing ensures that your UI doesn't change unexpectedly. Further, we'll be using theĀ ...
Read more >Use Jest's Snapshot Testing Feature
Before Jest snapshotting, when I wrote this kind of test, I would console log the results and then copy/paste it into my assertion...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
This error still continues. Iām with the latest version of jest.
This is my configuration:
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. Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.