insta
insta copied to clipboard
Show diffs on `cargo insta test`?
Currently when a snapshots needs updating, cargo insta test doesn't show a diff, only:
info: 1 snapshot to review
use `cargo insta review` to review snapshots
[Command exited with 1]
Seeing a diff can be really useful — for example, I often run tests on any file change, and being able to view the diff while adjusting code allows for really fast feedback.
To see a diff, we instead need to run cargo insta test --check. But this has some disadvantages:
- It doesn't write pending snapshots
- It exits early when it encounters the first error
- It requires switching commands — when
watchexec -- cargo insta test --checkis running, we then need to exit and change tocargo insta test --acceptwhen we want to accept the snapshot - (another approach is running
cargo insta test --acceptin the loop and viewing the diff in git — but because the test passes, we don't get any debug output, and it requires another watch process to update the git diff)
Should we show the diff when running cargo insta test? The downside is that the diff can be huge, and so could potentially overwhelm a terminal. One option would be to print some of a diff, and then print "limiting diff output to 300 lines, run cargo insta --check for a full output, or cargo insta review to review each diff"