americanexpress / jest-image-snapshot

✨ Jest matcher for image comparisons. Most commonly used for visual regression testing.
Apache License 2.0
3.81k stars 197 forks source link

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

Open deanohyeah opened 2 years ago

deanohyeah commented 2 years ago

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 commented 3 weeks ago

Any updates on this?