Skip to content
Latchkey

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.

Jest output
› 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

Terminal
jest -u            # removes obsolete snapshot keys locally
git add **/*.snap  # commit the pruned snapshots

Keep CI strict but clean

  1. Run CI with --ci so missing/obsolete snapshots fail instead of silently writing.
  2. After renaming a describe/test, re-run -u locally to drop the old keys.
  3. Review .snap diffs in PRs so orphaned entries are caught before merge.

How to prevent it

  • Run jest -u after renaming or deleting snapshot tests.
  • Review snapshot file diffs in code review.
  • Keep CI on --ci so stale snapshots surface immediately.

Frequently asked questions

What causes ""N obsolete snapshots found""?
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.
How do I fix "N obsolete snapshots found"?
Prune obsolete snapshots locally and commit

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card