Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jest doesn't write new snapshots automatically in watch mode if another snapshot has been updated #4869

Closed
gsteacy opened this issue Nov 10, 2017 · 2 comments · Fixed by #5256

Comments

@gsteacy
Copy link

gsteacy commented Nov 10, 2017

Do you want to request a feature or report a bug?

Bug

What is the current behavior?

Jest does not automatically write new snapshots in watch mode if a previous snapshot has been updated in the current watch session, even if that snapshot is for another test suite. Instead, it prints the following message:

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.

This applies in --watch and --watchAll modes.

If the current behavior is a bug, please provide the steps to reproduce and either a repl.it demo through https://repl.it/languages/jest or a minimal repository on GitHub that we can yarn install and yarn test.

Repro available here: https://github.com/gsteacy/jest-bug-repro

  1. Cause one of the snapshot tests in src/Person.test.js to fail
  2. Press u to update the snapshot
  3. Uncomment the last test and note the message as above

What is the expected behavior?

Jest writes a snapshot for the new test.

Note that if you quit instead of forcing it to write the new snapshot with u, the snapshot will be written the next time you run Jest. Also, if you uncomment the test before updating any snapshots then the snapshot is written as expected.

Please provide your exact Jest configuration and mention your Jest, node, yarn/npm version and operating system.

Tried on two different systems.

OS: Windows 8.1 x64
Node: 8.9.1
npm: 5.5.1
yarn: 1.3.2
Jest: 21.2.1
Shell: Tried both Windows Command Prompt and Git Bash (which I believe uses Mintty as a terminal emulator)

OS: Windows 7 x64
Node: 6.11.2
npm: 3.10.10
Jest: 21.2.1
Shell: Both Windows Command Prompt and Git Bash

@WickyNilliams
Copy link

Same issue here - but on OSX Sierra.

@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 13, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants