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

Tests should fail when snapshots are added in CI environment #281

Open
deanohyeah opened this issue Nov 12, 2021 · 2 comments
Open

Tests should fail when snapshots are added in CI environment #281

deanohyeah opened this issue Nov 12, 2021 · 2 comments

Comments

@deanohyeah
Copy link

Currently, if a snapshot doesn't exist it is automatically added and passes.
https://github.com/americanexpress/jest-image-snapshot/blob/main/src/diff-snapshot.js#L207

To be inline with jest snapshots it should fail when CI=true and new snapshots are added.
https://jestjs.io/docs/snapshot-testing#are-snapshots-written-automatically-on-continuous-integration-ci-systems

snapshots in Jest are not automatically written when Jest is run in a CI system without explicitly passing --updateSnapshot. It is expected that all snapshots are part of the code that is run on CI and since new snapshots automatically pass, they should not pass a test run on a CI system. It is recommended to always commit all snapshots and to keep them in version control.

@jleifeld
Copy link

jleifeld commented Jun 7, 2024

Any updates on this?

@amosjyng
Copy link

I do get the error message

Error: 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.

when the CI environment variable is set to true. In fact, there's a specific test that checks for CI behavior. I haven't dug into the code to see how CI support is actually implemented, but this issue is likely already done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants