Automatically rerun tests after updating snapshots.
See original GitHub issueEnvironment
-
node -v
: [v9.0.0] -
npm -v
: [5.5.1], yarn v1.3.2 -
npm ls react-scripts
(if you haven’t ejected): [fill] -
Operating system: [react-scripts@1.0.17]
Steps to Reproduce
[Pre-cond]: all tests passing.
- Change the code so that there is an expected snapshot failing.
- Output shows correct information that there is a snapshot failing and the editor offers replacing the snapshots with the new ones.
- Confirm by clicking on
Replace them
in the Info box. - The info box shows
Updated Snapshots. It will show in your next test run.
. - Close the Info box by clicking on Close button.
- The OUTPUT still shows the test failure.
- Perform Save on the file that caused the snapshot failure.
Expected Behavior
- The relevant tests will re-run and the relevant errors will be cleared in Problems tab.
Actual Behavior
- Instead, the OUTPUT sometimes shows:
No tests found related to files changed since last commit. Press
ato run all tests, or run Jest with --watchAll.
In such a case thePROBLEMS
tab still shows failing Snapshot test.
It would be nice to get an Option (e.g. via CMD-SHIFT-P) to force re-run all the tests. Otherwise it is hard to clean up the PROBLEMS
tab and it is annoying. I see there is an enhancement proposed for just doing this, but this is still not optimal solution for a nice snapshot-testing flow.
A natural behaviour with snapshot testing is to re-run the relevant tests immediately after replacing snapshots. The Updated Snapshots. It will show in your next test run.
confirmation is redundant and off-the flow. Also doing ‘dummy’ save on the file that caused the snapshot failure, hopping to trigger a test rerun is not natural (and it does not always work).
Reseting Jest Runner (Stop/Start) will clear the errors in the PROBLEMS
tab, but it is also not how one would like to go through the process.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:2
- Comments:13 (9 by maintainers)
Top GitHub Comments
Related: There’s also discussion in Jest around having a JS API for running a test, which could mean that some of this process faffing could be simplified: https://github.com/facebook/jest/issues/5048#issuecomment-350677931
@connectdotz I moved discussion on this to #189. I will replay to your comments there.