insta
insta copied to clipboard
`--delete-unreferenced-snapshots` does not delete .snap files ignored by .gitignore/.ignore
What happened?
I expected --delete-unreferenced-snapshots to delete all the snap files under the snapshots folder that are not used in the tests, but apparently, this has no effect.
Reproduction steps
- create a snap file under the snapshots folder
- run
cargo insta test --delete-unreferenced-snapshots - See the snap file not being removed
Insta Version
1.19.0
rustc Version
rustc 1.64.0-nightly (1b57946a4 2022-08-03)
What did you expect?
Removal of excess snap files
Did the tests pass or did the process fail with an error? The deletion will only happen if all tests passed.
The tests passed. I used insta test --review --delete-unreferenced-snapshots --accept-unseen command (more sensible defaults for me)
I cannot reproduce this. The command works for me. Can you create a test case in a repo that shows the issue?
Here you go. I think the trick is to add the snap files to the gitignore. That apparently breaks the flag.
https://github.com/aminya/insta-unreferenced-bug
That makes sense. This is very much intentional to ignore files which are not tracked in version control. The assumption is that this does not happen in practice. I will change the description of the issue.
I think this can be closed as completed now we have include_ignored?