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

cargo-insta cannot find snapshots in non-default directories #70

Closed
LPGhatguy opened this issue Sep 4, 2019 · 7 comments
Closed

cargo-insta cannot find snapshots in non-default directories #70

LPGhatguy opened this issue Sep 4, 2019 · 7 comments

Comments

@LPGhatguy
Copy link
Contributor

LPGhatguy commented Sep 4, 2019

Hi! I just upgraded to insta 0.11 and started taking advantage of the Settings struct to partition my snapshots a little more.

My tests are roughly of this shape:

let mut settings = insta::Settings::new();

let snapshot_path = Path::new(env!("CARGO_MANIFEST_DIR")).join("serve-test-snapshots");
settings.set_snapshot_path(snapshot_path);

settings.bind(|| {
    // Do the actual test

    assert_yaml_snapshot!(info, {
        ".sessionId" => "[session id]"
    });
});

When I get a snapshot failure, the .snap.new file is created in the correct place. The output tells me to run cargo insta review.

I run cargo insta review --all instead because I'm running in a workspace, but Insta tells me I have no snapshots to review:

lgreathouse /c/projects/rojo (master)
$ cargo insta review --all
done: no snapshots to review

...but I know it's lying, since my tests are still failing!

This issue also causes cargo insta test to fail, since it cannot find the snapshots that were just created. This means that the snippet recommended in the changelog to upgrade to 0.11.0 doesn't finish!

@LPGhatguy
Copy link
Contributor Author

LPGhatguy commented Sep 9, 2019

It looks like my snapshots are found if I use --workspace-root, but only if my current working directory is NOT the workspace root.

For example:

lgreathouse /c/projects/rojo (master)
$ cargo insta review --all
done: no snapshots to review

lgreathouse /c/projects/rojo (master)
$ cargo insta review --all --workspace-root .
done: no snapshots to review

lgreathouse /c/projects/rojo (master)
$ cd ..

lgreathouse /c/projects
$ cargo insta review --all --workspace-root rojo
(review UI pops up)

I noticed this because I cloned Insta and started poking at the code to see if I could fix this issue, and the issue magically did not happen when I was testing against master!

@mitsuhiko
Copy link
Owner

I cannot reproduce this. Should this issue be closed?

@LPGhatguy
Copy link
Contributor Author

I can try again when I get back into work this week and see if I can get you a minimal reproduction!

@LPGhatguy
Copy link
Contributor Author

Still happening on the project that this affects. I'll upgrade to Insta 0.12.0 and see if I can get a small repro case.

@mkantor
Copy link
Contributor

mkantor commented Sep 1, 2020

Just chiming in to confirm that this does in fact still happen. Here's a repro.

@mkantor
Copy link
Contributor

mkantor commented Sep 1, 2020

I tracked the cause down to load_snapshot_containers. Going down the Some branch in that function means that snapshots are only searched for inside the source path of each package, not the workspace root.

mkantor added a commit to mkantor/operator that referenced this issue Sep 1, 2020
cargo-insta does not like the previous location.

See <mitsuhiko/insta#70>.
mkantor added a commit to mkantor/operator that referenced this issue Sep 1, 2020
cargo-insta does not like the previous location.

See <mitsuhiko/insta#70>.
@mitsuhiko
Copy link
Owner

Thanks. Fixed!

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

3 participants