Skip to content

feat(snapshot): report snapshot files no test resolved - #911

Merged
Chemaclass merged 1 commit into
mainfrom
feat/902-report-unused-snapshots
Jul 27, 2026
Merged

feat(snapshot): report snapshot files no test resolved#911
Chemaclass merged 1 commit into
mainfrom
feat/902-report-unused-snapshots

Conversation

@Chemaclass

Copy link
Copy Markdown
Member

🤔 Background

Related #902

A snapshot is named after its test file and function, so renaming or deleting a test orphans the file. Nothing reads it, nothing reports it, and it survives every run — leaving the next reader of snapshots/ unable to tell which files are live.

💡 Changes

  • Add --snapshot-report-unused: resolved paths are collected into the run dir (only when the flag is on) and diffed against what is on disk after the run.
  • Nothing is deleted, deliberately — a snapshot removed by mistake is re-recorded on the next run and never fails again, so an automatic cleanup could turn a real assertion into a rubber stamp.
  • Refused alongside --filter, --tag, --exclude-tag, --shard and --rerun-failed, whose partial runs would list live files as unused.
  • Documented in the snapshots and command-line pages, with an acceptance test using an orphaned fixture.

Scoping needed more than the issue described: restricting the report to the run's snapshot directories still flagged every snapshot owned by a test file the run did not include (running one file listed a dozen live snapshots). It now only considers snapshots whose owning test file was discovered this run, which the filename encodes.

A snapshot is named after its test file and function, so renaming or deleting a
test orphans the file: nothing reads it, nothing reports it, and it survives
every run. The next reader of snapshots/ cannot tell which files are live.

Add --snapshot-report-unused. Resolved paths are collected into the run dir
(only when the flag is on, so a normal run pays nothing) and diffed against
what is on disk after the run.

Nothing is deleted, deliberately: a snapshot removed by mistake is re-recorded
on the next run and never fails again, so an automatic cleanup could turn a real
assertion into a rubber stamp.

Scoping needed more than the issue described. Restricting the report to the
snapshot directories of the run still flagged every snapshot owned by a file the
run did not include — running one test file listed a dozen live snapshots. The
report therefore only considers snapshots whose owning test file was discovered
this run, which is recoverable from the filename. A partial run of the tests
*within* those files is still misleading, so the flag is refused alongside
--filter, --tag, --exclude-tag, --shard and --rerun-failed.

Closes #902
@Chemaclass Chemaclass added the enhancement New feature or request label Jul 27, 2026
@Chemaclass Chemaclass self-assigned this Jul 27, 2026
@Chemaclass
Chemaclass merged commit 8ae0e1b into main Jul 27, 2026
37 checks passed
@Chemaclass
Chemaclass deleted the feat/902-report-unused-snapshots branch July 27, 2026 21:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant