From 0a3951e696e340857bf918095b6d64a693a90519 Mon Sep 17 00:00:00 2001 From: Florian Plattner Date: Fri, 4 Oct 2024 23:59:39 +0200 Subject: [PATCH] Add section on binary snapshots --- content/docs/snapshot-types.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/content/docs/snapshot-types.md b/content/docs/snapshot-types.md index 237793d..46c484e 100644 --- a/content/docs/snapshot-types.md +++ b/content/docs/snapshot-types.md @@ -80,6 +80,23 @@ accept the change. The file will then be updated automatically and the reference value will be placed in the macro invocation. Note that inline snapshots require the use of `cargo-insta`. +## Binary snapshots (experimental) + +Binary snapshots store their content in a separate file next to the metadata +file. This enables opening them in external tools. They are simply compared byte +for byte. + +```rust +#[test] +fn test_something() { + // implicit name: + insta::assert_binary_snapshot!(".txt", b"abcd".to_vec()); + + // named: + insta::assert_binary_snapshot!("my_snapshot.bin", [0, 1, 2, 3].to_vec()); +} +``` + ## Debug expressions Snapshots optionally accept a debug expression, which can be helpful for adding