insta icon indicating copy to clipboard operation
insta copied to clipboard

Exclude folders from `--unreferenced=reject` checks

Open Turbo87 opened this issue 4 weeks ago • 2 comments

In the crates.io codebase we have a mix of Rust and JS code. We use insta for a lot of the Rust code, and increasingly vitest for the JS code.

We use cargo insta test --require-full-match --unreferenced=reject to run the Rust test suite on CI. This worked fine until we tried to use the snapshot feature of vitest, which unfortunately also creates .snap files. These files now get picked up by cargo-insta and reported as unreferenced insta snapshots.

Is there some way to influence what paths are relevant to the "unreferenced snapshots" detection? What I've seen so far are options for gitignored and hidden files, but those unfortunately won't solve our issue.

If there is no such option yet, would there be interest in supporting such a use case? I'm happy to do the implementation work, but we should probably first talk about how this should look like to the enduser :)

Turbo87 avatar Dec 17 '25 09:12 Turbo87

interesting q!

what's the format of the other snapshot files? we could do a check of remaining files' headers and check they're insta files?

max-sixty avatar Dec 17 '25 10:12 max-sixty

what's the format of the other snapshot files? we could do a check of remaining files' headers and check they're insta files?

// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html

exports['toUpperCase 1'] = '"FOOBAR"'

apparently they look quite different. more information is available at https://vitest.dev/guide/snapshot.html#use-snapshots.

Turbo87 avatar Dec 17 '25 11:12 Turbo87