Jest "obsolete snapshots" Fail CI with --ci - Stale .snap Entries
Renaming or deleting a test leaves its stored snapshot key orphaned in the .snap file. Locally Jest auto-prunes these, but with --ci it refuses to write - and a CI check that treats obsolete snapshots as a failure then breaks the build.
What this error means
CI reports "N obsolete snapshots found" after a green test run. The tests pass, but a strict snapshot gate (or --ci with a check) fails because stale .snap entries were never removed and committed.
› 2 snapshots obsolete.
↳ src/__snapshots__/Card.test.tsx.snap
• <Card /> renders old layout 1
• <Card /> renders old layout 2
(use --updateSnapshot / -u to remove them - not run with --ci)Common causes
Snapshot keys orphaned by renamed/removed tests
A test was renamed or deleted, but its snapshot entry still lives in the .snap file. The key no longer maps to any test, so Jest flags it as obsolete.
--ci never auto-prunes
In --ci mode Jest will not rewrite .snap files, so obsolete entries are reported rather than cleaned. A gate that fails on obsolete snapshots then breaks CI.
How to fix it
Prune obsolete snapshots locally and commit
jest -u # removes obsolete snapshot keys locally
git add **/*.snap # commit the pruned snapshotsKeep CI strict but clean
- Run CI with
--ciso missing/obsolete snapshots fail instead of silently writing. - After renaming a describe/test, re-run
-ulocally to drop the old keys. - Review
.snapdiffs in PRs so orphaned entries are caught before merge.
How to prevent it
- Run
jest -uafter renaming or deleting snapshot tests. - Review snapshot file diffs in code review.
- Keep CI on
--ciso stale snapshots surface immediately.