jest.retryTimes() gets confused with snapshots
See original GitHub issue🐛 Bug Report
Each retry of a test with a snapshot is identified as a different snapshot. In addition a snapshot test that eventually passes exits as a test failure (exit code 1).
$ jest snapshot.test.js
PASS __tests__/snapshot.test.js
√ simple
› 2 snapshots failed.
Snapshot Summary
› 2 snapshots failed from 1 test suite. Inspect your code changes or run `yarn test -u` to update them.
Test Suites: 1 passed, 1 total
Tests: 1 passed, 1 total
Snapshots: 2 failed, 1 passed, 3 total
Time: 1.518s
Ran all test suites matching /snapshot.test.js/i.
error Command failed with exit code 1.
To Reproduce
// snapshot.test.js
jest.retryTimes(3);
let count = 0;
test('simple', () => {
count++;
const name = count === 3 ? 'pass' : 'fail';
expect('PASS').toMatchSnapshot(name);
});
Snapshot
// snapshot.test.js.snap
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`simple: fail 1`] = `FAIL`;
exports[`simple: fail 2`] = `"FAIL"`;
exports[`simple: pass 1`] = `"PASS"`;
Expected behavior
Snapshot retries should maintain the same name and should exit with 0 if it eventually passed
Link to repl or repo (highly encouraged)
Run npx envinfo --preset jest
System:
OS: Windows 10
CPU: (16) x64 AMD Ryzen 7 1700 Eight-Core Processor
Binaries:
Node: 10.14.1 - C:\Program Files\nodejs\node.EXE
Yarn: 1.12.3 - C:\Program Files\nodejs\yarn.CMD
npm: 6.4.1 - C:\Program Files\nodejs\npm.CMD
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:17 (7 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 Image Snapshot: A Jest Matcher for Image Comparisons
Jest matcher that performs image comparisons using pixelmatch and behaves just like Jest snapshots do! Very useful for visual regression testing.
Read more >When To Use Jest Snapshots - Selleo
toMatchSnapshot() and running the test for the first time. When snapshot gets outdated you can replace it with a fresh copy by running...
Read more >Jest-image-snapshot NPM
Want to get paid for your contributions to jest-image-snapshot ? ... jest.retryTimes(). Jest supports automatic retries on test failures.
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
Thank you
I’ll take a look! Thanks for reporting.