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

Do not write snapshots by default on CI #3456

Merged
merged 4 commits into from
May 4, 2017
Merged

Conversation

cpojer
Copy link
Member

@cpojer cpojer commented May 3, 2017

Summary

When running on a CI environment or with --ci, Jest will now refuse to write new snapshots. This is so that on CI, uncommitted snapshots will fail rather than pass by writing new files every time.

I introduced a --ci field and changed the updateSnapshot field into one of three states: none, all or new. None won't write any snapshot files, all will write all and clean snapshots up and new will only create new snapshots.

screen shot 2017-05-03 at 8 18 33 pm

Test plan

  • jest

@cpojer cpojer force-pushed the master branch 4 times, most recently from 6b25a98 to 4ff1379 Compare May 4, 2017 13:24
@cpojer
Copy link
Member Author

cpojer commented May 4, 2017

In the last commit, there are some unrelated changes because prettier was being funny. I think it's all fixed now and those are the properly printed values. Sorry for the churn there.

@cpojer cpojer merged commit e16431b into jestjs:master May 4, 2017
@kole
Copy link

kole commented May 19, 2017

Was this PR merged without any updates to the docs? I am getting the New snapshot was not written. The update flag must be explicitly passed to write a new snapshot. error in Travis and can't figure out how to get rid of it because there are no docs for how to correctly run snapshot tests in jest in a CI env.

P.S. I am adding the update flag... still getting this error.

@cpojer
Copy link
Member Author

cpojer commented May 19, 2017

It seems like you aren't adding snapshots to your CI and therefore using snapshots wrongly. The documentation is on the website: http://facebook.github.io/jest/docs/en/snapshot-testing.html#snapshots-are-not-written-automatically-on-continuous-integration-systems-ci

@kole
Copy link

kole commented May 24, 2017

@cpojer I am still struggling here. It seems like the point of this change is to prevent snapshot checks from running in a CI environment, but I cannot figure out why that is a good idea. All my snapshots are committed in the repo. So a snapshot check should pass or fail just like it does in a local dev env, no?

I have also since removed the -u flag and that is where problems are happening. If I add the -u flag, tests pass fine, obviously. But I want the CI build to fail if the snapshot check fails.

Thanks in advance for your guidance.

@kole
Copy link

kole commented May 24, 2017

Never mind. I think I get it now. The point of the change is to not allow snapshots to be created in a CI env. To give snapshot changes a better chance to truly fail.

Sorry for the confusion.

tushardhole pushed a commit to tushardhole/jest that referenced this pull request Aug 21, 2017
* Better flow typings for snapshots.

* Remove `initializeSnapshotState`.

* Do not write snapshots by default on CI systems.

* Tests + updateSnapshot fixes.
@github-actions
Copy link

This pull request 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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants