Skip to content

Skip non-insta snapshot files in unreferenced detection#846

Merged
max-sixty merged 1 commit intomitsuhiko:masterfrom
max-sixty:discriminate-insta-snapshots
Dec 18, 2025
Merged

Skip non-insta snapshot files in unreferenced detection#846
max-sixty merged 1 commit intomitsuhiko:masterfrom
max-sixty:discriminate-insta-snapshots

Conversation

@max-sixty
Copy link
Copy Markdown
Collaborator

Summary

  • Adds is_likely_insta_snapshot() function that reads only 16 bytes to check for ---\nsource: prefix
  • Filters unreferenced snapshot detection to skip files that don't match insta's format
  • Adds functional tests for vitest and jest snapshot file preservation

This allows projects using both insta and other snapshot testing tools (like vitest or jest) to use --unreferenced=reject without false positives.

Fixes #845

Test plan

  • Added test_unreferenced_ignores_non_insta_snapshots - verifies vitest/jest .snap files are not deleted by --unreferenced=delete
  • Added test_unreferenced_reject_ignores_non_insta_snapshots - verifies --unreferenced=reject doesn't fail on non-insta .snap files
  • All existing tests pass

🤖 Generated with Claude Code

Adds a quick check (`is_likely_insta_snapshot`) that reads only the first
16 bytes of each `.snap` file and verifies it starts with `---\nsource:`
(or `---\r\nsource:` for CRLF). This distinguishes insta snapshots from
other snapshot formats (vitest, jest) that may use the same `.snap` extension.

Fixes mitsuhiko#845

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
@max-sixty
Copy link
Copy Markdown
Collaborator Author

@Turbo87 lmk any feedback, ty

Copy link
Copy Markdown

@Turbo87 Turbo87 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

awesome, thanks a lot!! 😍

@max-sixty max-sixty merged commit ad233cd into mitsuhiko:master Dec 18, 2025
15 checks passed
@max-sixty
Copy link
Copy Markdown
Collaborator Author

great if you can install and try it out...

@Turbo87
Copy link
Copy Markdown

Turbo87 commented Dec 18, 2025

you mean cargo install from git? it's not released yet, right?

@max-sixty
Copy link
Copy Markdown
Collaborator Author

yes!

@Turbo87
Copy link
Copy Markdown

Turbo87 commented Dec 18, 2025

great if you can install and try it out...

info: no unreferenced snapshots found

seems to work perfectly. thanks again! :)

@max-sixty max-sixty deleted the discriminate-insta-snapshots branch December 18, 2025 18:07
@max-sixty max-sixty mentioned this pull request Dec 18, 2025
2 tasks
max-sixty added a commit that referenced this pull request Dec 18, 2025
## Summary

- Add external diff tool support via `INSTA_DIFF_TOOL` environment
variable (#844)
- Add `test.disable_nextest_doctest` config option to `insta.yaml`
(#842)
- Skip non-insta snapshot files in unreferenced detection (#846)
- Collect warnings from tests for display after run (#840)
- Update TOML serialization to be up-to-date and backwards-compatible
(#834)
- Support `clippy::needless_raw_strings` lint (#828)

## Test plan

- [x] All tests pass
- [x] All lints pass

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Exclude folders from --unreferenced=reject checks

2 participants