feat(snapshot): report snapshot files no test resolved - #911
Merged
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🤔 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
--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.--filter,--tag,--exclude-tag,--shardand--rerun-failed, whose partial runs would list live files as unused.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.