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

Change behavior of --force-update-snapshots to always update #630

Closed
max-sixty opened this issue Oct 1, 2024 · 0 comments
Closed

Change behavior of --force-update-snapshots to always update #630

max-sixty opened this issue Oct 1, 2024 · 0 comments

Comments

@max-sixty
Copy link
Collaborator

--force-update-snapshots writes a snapshot when the contents don't match exactly — for example the reference snapshot has a legacy format or slightly incorrect metadata. Despite its name, it doesn't write snapshots that do match exactly.

I've done a lot of work on improving many edge cases there. But I think that may have been a fool's errand, and we should instead just write every snapshot when --force-update-snapshots is passed.

In particular, insta can't capture the surrounding delimiters of inline snapshots (because we don't want to add a serde dependency to insta, only to cargo-insta), so we can't identify whether we need to update the snapshot for that reason. In that case, there's currently no way to update snapshots except for manually breaking them and rerunning cargo insta test --accept.

So I would propose that the behavior should be:

  • --force-update-snapshots writes every snapshot, whether or not it perceives it's required
    • Potentially it implies --accept to reduce the noise of new files
  • --require-full-match takes most of the existing function of --force-update-snapshots — i.e. comparing the exact snapshot, as much as insta can perceive, while ignoring any snapshots that it perceives as identical.
    • Unlike --force-update-snapshots, it'll also fail on any discrepancies, but I don't think that's necessarily bad
@max-sixty max-sixty changed the title Change behavior of --force-update-snapshots to always write Change behavior of --force-update-snapshots to always update Oct 1, 2024
max-sixty added a commit to max-sixty/insta that referenced this issue Oct 6, 2024
As discussed in mitsuhiko#630

Will wait for a few days before merging.
max-sixty added a commit that referenced this issue Oct 7, 2024
As discussed in #630

Will wait for a few days before merging.
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