question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Automatically rerun tests after updating snapshots.

See original GitHub issue

Environment

  1. node -v: [v9.0.0]

  2. npm -v: [5.5.1], yarn v1.3.2

  3. npm ls react-scripts (if you haven’t ejected): [fill]

  4. Operating system: [react-scripts@1.0.17]

Steps to Reproduce

[Pre-cond]: all tests passing.

  1. Change the code so that there is an expected snapshot failing.
  2. Output shows correct information that there is a snapshot failing and the editor offers replacing the snapshots with the new ones.
  3. Confirm by clicking on Replace them in the Info box.
  4. The info box shows Updated Snapshots. It will show in your next test run..
  5. Close the Info box by clicking on Close button.
  6. The OUTPUT still shows the test failure.
  7. Perform Save on the file that caused the snapshot failure.

Expected Behavior

  1. The relevant tests will re-run and the relevant errors will be cleared in Problems tab.

Actual Behavior

  1. Instead, the OUTPUT sometimes shows: No tests found related to files changed since last commit. Press a to run all tests, or run Jest with --watchAll. In such a case the PROBLEMS 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:open
  • Created 6 years ago
  • Reactions:2
  • Comments:13 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
ortacommented, Dec 11, 2017

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

0reactions
marcinczenkocommented, Dec 12, 2017

@connectdotz I moved discussion on this to #189. I will replay to your comments there.

Read more comments on GitHub >

github_iconTop 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: How to Update Snapshot Tests - In Plain English
Run the snapshot test, make sure it passes — if it does not pass, find the problem and fix it, don't change the...
Read more >
How do I update the snapshots in my React/TypeScript project?
Run Jest from the terminal instead. Solution #1: For the failing test suite requiring snapshots, open a terminal and run. npm test <filename>....
Read more >
What I Learned at Work this Week: Updating a Jest Snapshot
There's a single-line command to automatically update our Jest snapshots. Even better, when our tests fail, we're given the option to make a ......
Read more >
Creating snapshots in Jest for testing React applications
Select the u option to update the snapshot when Jest is in watch mode . Updating the snapshot tells Jest that the changes...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found