Jest Snapshot Mismatch - "1 snapshot failed" / Obsolete in CI
A snapshot test compared rendered output against a stored .snap and they differ. Either the UI legitimately changed (update the snapshot), or the output is non-deterministic (dates, IDs) and changes every run.
What this error means
CI fails with "1 snapshot failed" and a diff of expected vs received. In --ci mode Jest will not write new snapshots - a missing snapshot is a failure, not an auto-create as it is locally.
● <Card /> renders › matches snapshot
expect(received).toMatchSnapshot()
Snapshot name: `<Card /> renders matches snapshot 1`
- Snapshot - 1
+ Received + 1
- <span>Updated 2 days ago</span>
+ <span>Updated 3 days ago</span>Common causes
Intentional UI change not committed
The component changed on purpose but the stored snapshot was not updated, so every run diffs. Run --updateSnapshot and commit the new .snap.
Non-deterministic output
Snapshots containing dates, random IDs, or unsorted data differ on every run. They must be normalized or those values mocked.
CI mode never auto-writes snapshots
Locally a missing snapshot is created and passes; with --ci (or CI=true) Jest fails instead of writing, surfacing snapshots that were never committed.
How to fix it
Update and commit intentional changes
jest -u # update snapshots locally
git add **/*.snap # commit the regenerated snapshotsMake snapshots deterministic
- Mock dates/clock (
jest.useFakeTimers().setSystemTime(...)) and any random IDs. - Use property matchers:
toMatchSnapshot({ id: expect.any(String) }). - Sort collections before snapshotting so order is stable.
How to prevent it
- Commit
.snapfiles and review their diffs in PRs. - Mock time and randomness in snapshot tests.
- Run CI with
--ciso missing snapshots fail instead of silently writing.