-
-
Notifications
You must be signed in to change notification settings - Fork 6.6k
Closed
Labels
Description
π 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.CMDsbekrin