mitsuhiko / insta

A snapshot testing library for rust
https://insta.rs
Apache License 2.0
2.26k stars 102 forks source link

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

Closed max-sixty closed 1 month ago

max-sixty commented 2 months ago

--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: