ITADN

assert_toml_snapshot seems broken

#879Closedip1981 创建于 2026-02-26
bug
I
ip1981commented
### What happened? Trying to test any struct against a TOML snapshots fails: ``` ---- tests::test_toml stdout ---- thread 'tests::test_toml' (844475) panicked at /home/pashev/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/insta-1.46.3/src/serialization.rs:174:64: called `Result::unwrap()` on an `Err` value: UnsupportedType(None) note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace ``` ### Reproduction steps 1. Simple cargo project (`Cargo.toml`): ``` [package] name = "fuckinsta" version = "0.1.0" edition = "2024" [dependencies] [dev-dependencies] insta = { version = "1.46.3", features = [ "json", "toml" ] } ``` 2. Trivial `src/lib.rs`: ``` #[cfg(test)] mod tests { #[test] fn test_json() { let result = vec![1, 2, 3]; insta::assert_json_snapshot!(result); } #[test] fn test_toml() { let result = vec![1, 2, 3]; insta::assert_toml_snapshot!(result); } } ``` 3. Results of `cargo test`: ``` 19:16 $ cargo test Compiling fuckinsta v0.1.0 (/home/pashev/tmp/fuckinsta) Compiling insta v1.46.3 Finished `test` profile [unoptimized] target(s) in 1.01s Running unittests src/lib.rs (target/debug/deps/fuckinsta-cec04a8fd5a17f5a) running 2 tests test tests::test_toml ... FAILED stored new snapshot /home/pashev/tmp/fuckinsta/src/snapshots/fuckinsta__tests__json.snap.new test tests::test_json ... FAILED failures: ---- tests::test_toml stdout ---- thread 'tests::test_toml' (844475) panicked at /home/pashev/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/insta-1.46.3/src/serialization.rs:174:64: called `Result::unwrap()` on an `Err` value: UnsupportedType(None) note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace ---- tests::test_json stdout ---- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ Snapshot Summary ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ Snapshot file: src/snapshots/fuckinsta__tests__json.snap Snapshot: json Source: src/lib.rs:7 ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── Expression: result ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── +new results ────────────┬──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── 1 │+[ 2 │+ 1, 3 │+ 2, 4 │+ 3 5 │+] ────────────┴──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── To update snapshots run `cargo insta review` Stopped on the first failure. Run `cargo insta test` to run all snapshots. thread 'tests::test_json' (844474) panicked at /home/pashev/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/insta-1.46.3/src/runtime.rs:719:13: snapshot assertion for 'json' failed in line 7 failures: tests::test_json tests::test_toml test result: FAILED. 0 passed; 2 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.09s ``` ### rustc Version rustc 1.92.0 (ded5c06cf 2025-12-08) ### insta Version 1.46.3 ### cargo insta --version output cargo-insta 1.46.3 ### What did you expect? A new snapshot file with proper TOML.
关闭于 2026-02-26 2 条评论