Skip to content
Latchkey

Jest Obsolete Snapshots / "--ci" Won't Write New Snapshots

In --ci mode Jest refuses to write snapshots. A snapshot that was never committed fails (instead of being created as it would locally), and snapshots no longer referenced are reported as obsolete.

What this error means

CI reports "New snapshot was not written. The update flag must be explicitly passed..." for a missing snapshot, or "N obsolete snapshots found." Locally the same run passes because Jest auto-writes there.

jest
› 1 snapshot written.   <-- locally

# in CI (--ci):
New snapshot was not written. The update flag must be explicitly passed
to write a new snapshot.
  › 1 snapshot not written.

Common causes

Snapshot never committed

The .snap file was created locally but not committed. Locally Jest writes it and passes; with --ci (or CI=true) it fails instead of writing.

Obsolete snapshots left behind

A renamed or deleted test leaves stale entries in the .snap file. With --ci Jest will not prune them and flags them as obsolete.

How to fix it

Generate and commit snapshots locally

Terminal
jest -u            # write/update snapshots locally
git add **/*.snap  # commit them so CI has them

Prune obsolete snapshots

  1. Run jest --ci=false -u locally to remove obsolete entries.
  2. Confirm renamed tests no longer reference old snapshot names.
  3. Keep --ci in CI so missing snapshots fail loudly instead of being written.

How to prevent it

  • Commit .snap files and review their diffs in PRs.
  • Run CI with --ci so missing snapshots fail rather than write.
  • Periodically prune obsolete snapshots locally.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →