Interactive Snapshot Mode not working when snapshotName specified
See original GitHub issueSorry for the long issue, but I tried to give as much insights as possible as this issue was hard to spot at first and kind of hard to repro…
🐛 Bug Report
Interactive Snapshot Mode runs endlessly if multiple snapshots with snapshotName
in a test file break.
Even if I update the failing snapshots, the interactive shell goes back to the same diff error with this error printed :
New snapshot was not written. The update flag must be explicitly passed to write a new snapshot.
This is likely because this test is run in a continuous integration (CI) environment in which snapshots are not written by default.
To Reproduce
- Create a test file with this content :
// my.test.js
describe('those tests', () => {
test('will fail', () => {
expect({ a: 2 }).toMatchSnapshot({
a: 2
}, 'snaphot 1');
});
test('will also fail', () => {
expect({ a: 1 }).toMatchSnapshot({
a: 1
}, 'snapshot 2');
});
});
- run
$ yarn --watch my.test.js
- tests pass, snapshot are written for the first time
- modify all asserted objects (you can just copy/paste following code):
// my.test.js
describe('those tests', () => {
test('will fail', () => {
expect({ a: 5 }).toMatchSnapshot({
a: 5
}, 'snaphot 1');
});
test('will also fail', () => {
expect({ a: 4 }).toMatchSnapshot({
a: 4
}, 'snapshot 2');
});
});
- tests break, hit
i
key to enter Interactive Snapshot Mode - hit
u
key to update first failing snapshot - hit
u
key to update last failing snapshot - snapshot successfully updated :
Interactive Snapshot Result
› 2 snapshots reviewed, 2 snapshots updated
- hit
enter
key to end Interactive Snapshot Mode - shell goes back to first failing snapshot because Jest didn’t actually updated snapshot on filesystem
New snapshot was not written. The update flag must be explicitly passed to write a new snapshot.
This is likely because this test is run in a continuous integration (CI) environment in which snapshots are not written by default.
Expected behavior
At step 10, Jest should print a success message saying that all snapshots have been written.
// expected output
PASS 05_jest-snapshot/__tests__/my.test.js
those tests
✓ will fail (1ms)
✓ will also fail (1ms)
› 1 snapshot written.
Snapshot Summary
› 1 snapshot written from 1 test suite.
Test Suites: 1 passed, 1 total
Tests: 2 passed, 2 total
Snapshots: 1 written, 1 passed, 2 total
Time: 0.11s, estimated 1s
Ran all test suites related to changed files.
- If you remove snapshot names
snapshot 1
andsnapshot 2
and go through the same steps above, Jest will behave correctly at step 10. - it seems to work if the test file
my.test.js
contains only onetest
block :
describe('those tests', () => {
test('will fail', () => {
expect({ a: 52 }).toMatchSnapshot({
a: 52
}, 'snaphot 1');
});
});
Link to repl or repo (highly encouraged)
https://github.com/mr-wildcard/jest-snapshot-interactive-mode
Run npx envinfo --preset jest
System:
OS: macOS High Sierra 10.13.6
CPU: x64 Intel(R) Core(TM) i7-4770HQ CPU @ 2.20GHz
Binaries:
Node: 8.11.3 - ~/.nvm/versions/node/v8.11.3/bin/node
Yarn: 1.9.4 - /usr/local/bin/yarn
npm: 5.6.0 - ~/.nvm/versions/node/v8.11.3/bin/npm
npmPackages:
jest: ^23.6.0 => 23.6.0
Issue Analytics
- State:
- Created 5 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
no interaction in interactive snapshot mode - Stack Overflow
I use jest 23.2.0 for my current project. If I run jest --watchAll some snapshot tests fail. I press i to go to...
Read more >SVMDR failed to create Snapshot copy due to error sourceVol ...
Issue. A specific volume or set of volumes involved in an SVMDR relationship fails with the following error.
Read more >Overview of ZFS Snapshots (Solaris ZFS Administration Guide)
Snapshots are created by using the zfs snapshot command, which takes as its only argument the name of the snapshot to create. The...
Read more >HPE Recovery Manager Central 6.3.x CLI Reference Guide
With RMC-S, the command only supports the online backup of an entire SQL database ... If not specified, RMC-S creates the snapshot using...
Read more >h13697-dell-emc-powermax-vmax-all-flash-timefinder-snapvx ...
TimeFinder legacy modes: Mirror, Clone, and VP Snap . ... storage array and are not specific to snapshots. The following are explanations of...
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
I confirmed that the root cause of this is #7197 so going to close in favor of that
Thanks again for the report @mr-wildcard!
I added a repo for reproduction steps 😉 (https://github.com/mr-wildcard/jest-snapshot-interactive-mode)