josecelano / cargo-pretty-test

A Rust command that prettifies the ugly `cargo test` output into a beautiful one.
https://users.rust-lang.org/t/cargo-test-output-with-indentation/100149
135 stars 1 forks source link

Snapshot may fail without any reason #8

Closed zjp-CN closed 11 months ago

zjp-CN commented 11 months ago
error: test failed, to rerun pass `-p cargo-pretty-test --test mocking_project`
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ Snapshot Summary ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Snapshot: snapshot_testing_for_parsed_output-3
Source: tests/mocking_project.rs:72
────────────────────────────────────────────────────────────────────────────────
Expression: detail
────────────────────────────────────────────────────────────────────────────────
-old snapshot
+new results
────────────┬───────────────────────────────────────────────────────────────────
    0     0 │ failures:
    1     1 │ 
    2     2 │ ---- submod::panic::panicked stdout ----
    3     3 │ thread 'submod::panic::panicked' panicked at 'explicit panic', tests/integration/src/lib.rs:9:13
    4       │-note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
    5     4 │ 
    6     5 │ ---- submod::panic::should_panic_but_didnt stdout ----
    7     6 │ note: test did not panic as expected
    8     7 │ 
────────────┴───────────────────────────────────────────────────────────────────
Stopped on the first failure. Run `cargo insta test` to run all snapshots.
thread 'snapshot_testing_for_parsed_output' panicked at 'snapshot assertion for 'snapshot_testing_for_parsed_output-3' failed in line 72', /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba1[50](https://github.com/josecelano/cargo-pretty-test/actions/runs/6284325975/job/17065587745#step:6:51)01f/insta-1.32.0/src/runtime.rs:[56](https://github.com/josecelano/cargo-pretty-test/actions/runs/6284325975/job/17065587745#step:6:57)3:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Sometimes the note "run with RUST_BACKTRACE=1 environment variable to display a backtrace" doesn't show up in the cargo test output which randomly fails the snapshot test on nightly or stable Rust.