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

Obsolete snapshots not detected #50

Open
askoufis opened this issue Mar 19, 2023 · 1 comment
Open

Obsolete snapshots not detected #50

askoufis opened this issue Mar 19, 2023 · 1 comment

Comments

@askoufis
Copy link

askoufis commented Mar 19, 2023

Obsolete snapshots are snapshots that were created by a test that no longer exists/had its name changed. These snapshots are not detected when running jest. This doesn't matter that much when running jest normally, they'll be removed the next time you update snapshots. However, when running on CI, it's often desirable to fail CI if there are obsolete snapshots. This is the behaviour that jest --ci does.

I believe these are referred to as unchecked snapshots within the jest source code. These are tracked in the snapshotState, so potentially adding them to the commonSnapshotState could fix the issue. I tried to do this but was unsuccessful.

Reproduction

  1. Create a file with 2 specific snapshots that write to the same file
  2. Run jest to create the snapshots
  3. Delete one of the snapshot tests
  4. Run jest --ci
  5. jest --ci should fail as there is an obsolete snapshot, but it passes and doesn't show any messaging about the obsolete snapshot
@igor-dv
Copy link
Owner

igor-dv commented Mar 21, 2023

Yeah, that's actually a known issue.. I wander why I didn't mention it in the readme 🤔 . The way it was worked-around in Storybook is to create an integrity test that will check abandoned files. you can take a look here https://github.com/storybookjs/storybook/blob/next/code/addons/storyshots-core/src/api/integrityTestTemplate.ts (this code was already changed many times from the last time I'have seen, so not sure what's going on there now =) )

I will try to find some time to test your direction. can't have an ETA though

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

2 participants