Jest ignores obsolete file snapshots if there are inline snapshots
See original GitHub issue🐛 Bug Report
Jest ignores obsolete file snapshots if there are inline snapshots in this test.
To Reproduce
Steps to reproduce the behavior:
test('test', () => {
expect('foo').toMatchSnapshot();
});
$ jest
PASS __tests__/test.js
✓ test (3ms)
› 1 snapshot written.
Snapshot Summary
› 1 snapshot written from 1 test suite.
Test Suites: 1 passed, 1 total
Tests: 1 passed, 1 total
Snapshots: 1 written, 1 total
Time: 2.244s
Ran all test suites.
Change the above test to use inline snapshots:
test('test', () => {
expect('foo').toMatchInlineSnapshot();
});
$ jest
PASS __tests__/test.js
✓ test (3ms)
› 1 snapshot written.
Snapshot Summary
› 1 snapshot written from 1 test suite.
Test Suites: 1 passed, 1 total
Tests: 1 passed, 1 total
Snapshots: 1 written, 1 total
Time: 2.302s
Ran all test suites.
Now both a file and an inline snapshots exists. The file snapshot is completely ignored, Jest doesn’t report that it’s obsolete and doesn’t remove it with jest -u
.
Expected behavior
Jest should fail on obsolete snapshots and remove them with jest -u
.
Issue Analytics
- State:
- Created 5 years ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
Snapshot Testing - Jest
Snapshot tests are a very useful tool whenever you want to make sure your UI does not change unexpectedly.
Read more >jest snapshot testing: how to ignore part of the snapshot file in ...
the question here: there are some components in my test that have a random values and i don't really care about testing them....
Read more >Jest - Obsolete snapshots are not detected : WEB-37035
recreated; there are no prompts to update snapshot. When running jest --watch , snapshot is reported to be obsolete;. Ran all test suites...
Read more >jest snapshot testing example, jest snapshot date, ui snapshot ...
Now both a file and an inline snapshots exists. The file snapshot is completely ignored, Jest doesn't report that it's obsolete and doesn't...
Read more >What's wrong with snapshot tests. Since snapshot ... - Medium
When you write expect(mycomponent).toMatchSnapshot() , Jest creates a snapshot file, like mytest.spec.js.snap , with all snapshots of your test file. You ...
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 FreeTop 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
Top GitHub Comments
https://github.com/facebook/jest/pull/6380 & https://github.com/facebook/jest/releases/tag/v23.3.0
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.