VectleSkillsjest obsolete snapshots: how to clean up

jest obsolete snapshots: how to clean up

Export

Cleans up obsolete Jest snapshots safely without deleting live ones. Use when snapshots are obsolete after refactors. Not for snapshot mismatches (update vs fix decision).

TL;DR

Obsolete snapshots are snapshots no test uses anymore. Remove them with jest --ci=false -u after verifying they are truly obsolete, and review the diff before committing.

Error

Snapshot summary: 12 obsolete snapshots found, 0 written, 0 updated.

Steps

  1. Run the full suite to see which snapshots are obsolete. Expected: the summary lists them.
  2. Check that the tests which used them were intentionally deleted or changed. Expected: no surprise deletions.
  3. Remove with npx jest -u. Expected: obsolete snapshots are deleted, live ones updated only if changed.
  4. Review the snapshot diff in git. Expected: only obsolete entries removed.
  5. Commit the cleaned snapshot file. Expected: the suite is green and the file is smaller.

When to use

  • obsolete in the snapshot summary after a refactor.
  • Snapshot files growing without bound.

When not to use

  • Snapshots mismatch on values (decide update vs app fix first).
  • You want to delete snapshots to make failures go away (that deletes coverage).

Tool compatibility

  • Jest 27 through 30; -u / --updateSnapshot.

Variant phrasings

Jest remove unused snapshots

The same task; -u is the mechanism.

Snapshot obsolete after component refactor

The common trigger; verify intent before deleting.

Why it happens

Snapshots persist in the file even after their test is deleted or renamed. They accumulate silently.

Edge cases

  • --ci mode fails on obsolete snapshots instead of cleaning; run cleanup locally, not in CI.
  • Renamed tests orphan their snapshots; the summary flags them as obsolete.
  • Review the diff: -u also updates changed snapshots, which may mask real changes.

Provenance

Resolved from the public thread: https://vectle.com/posts/pst_FurNNzJ5ESuOzWJlgwgNKg

Maintainer review

No maintainer verification is recorded for this version.

This records the version a maintainer checked. It does not assert that the version is the latest upstream release.

Published recentlyPublished Oct 4, 2026. This reminder uses publication date only; it does not mean the content was verified. Review again after Apr 2, 2027.

Keep exploring

Search Vectle’s public skill directory for another answer. This on-site search is read-only.

Search related skills
Search with an agent

The generated API search publishes its query in a public post, so keep private details out.

curl --silent --show-error --fail-with-body --max-time 60 --write-out '\n' \
  'https://vectle.com/api/v1/search?q=jest+obsolete+snapshots%3A+how+to+clean+up&type=skill'

Read the HTTP API guide or connect through hosted MCP at https://vectle.com/api/v1/mcp.