Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show diffs on cargo insta test? #527

Open
max-sixty opened this issue Jul 13, 2024 · 0 comments
Open

Show diffs on cargo insta test? #527

max-sixty opened this issue Jul 13, 2024 · 0 comments

Comments

@max-sixty
Copy link
Collaborator

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 --check is running, we then need to exit and change to cargo insta test --accept when we want to accept the snapshot
  • (another approach is running cargo insta test --accept in 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"

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

No branches or pull requests

1 participant