insta
insta copied to clipboard
`INSTA_UPDATE=no` still writes new snapshots
What happened?
Not a big deal personally, but was surprised by the behavior so I thought worth logging[^1].
INSTA_UPDATE=no still writes new files. The docs describe it as no: does not update snapshot files at all (just runs tests).
I would have thought it's similar to --check.
[^1]: Personally I almost always use --accept and use git as the diff...
Reproduction steps
Create a new snapshot test; test_upper2, and run
INSTA_UPDATE=no cargo insta test -- test_upper2
This will create a new .snap.new file.
Insta Version
cargo-insta 1.29.0
rustc Version
1.65
What did you expect?
Resetting and adding --check has the expected behavior — no new files are written:
INSTA_UPDATE=no cargo insta test --check -- test_upper2
I think that's because INSTA_UPDATE is overwritten by cargo insta test. This double use of envvars really needs to be cleaned up.
@mitsuhiko I came around to looking at this. clap has a bunch of ways of handling overriding env vars, such as default_value_if. That would let us get this & associated issues in order without lots of manual logic.
I know you want to keep dependencies light, so may be keen to stay on structopt rather than moving to clap.
How would you balance this? Notably this is in cargo-insta only, so maybe has less dependency pressure?