insta icon indicating copy to clipboard operation
insta copied to clipboard

Duplicated snapshots and os error 2 when running both integration and unit tests

Open dzfrias opened this issue 2 years ago • 1 comments

What happened?

When running insta, I get duplicated snapshot reviews, as well as a crash at the end of the snapshot reviewing. In the original (non-minimal) case, I wasn't able to review some of my tests.

I should have reviewed two snapshots, but only was able to review one. The error was the dreaded "No such file or directory (os error 2)".

Reproduction steps

  1. Create a new directory (not using cargo new --lib)
  2. Create a Cargo.toml
  3. Put this in your Cargo.toml:
[package]
name = "testing2"
version = "0.1.0"

[[test]]
name = "integration"
path = "tests/tests.rs"

[dev-dependencies]
insta = { workspace = true }

[workspace]
members = ["testing"]

[workspace.dependencies]
insta = "1.31"
  1. Run cargo new testing --lib in the project root
  2. Put this in testing/src/lib.rs
#[test]
fn it_works() {
    insta::assert_snapshot!("stuff...");
}
  1. Create the tests/ directory in the project root
  2. Create tests/tests.rs
  3. Put this in tests/tests.rs
#[test]
fn works() {
    insta::assert_snapshot!("hr");
}
  1. Run cargo insta test --review --all

Insta Version

1.31.0

rustc Version

1.71.0

What did you expect?

I expected to review two tests, and have no crash.

dzfrias avatar Jul 29 '23 19:07 dzfrias

I'm also struggling with this issue... I need to run things without --workspace, one-at-a-time, just to get insta to work!

TheLostLambda avatar Feb 22 '24 02:02 TheLostLambda