snapshot-testing

Crates.iosnapshot-testing
lib.rssnapshot-testing
version0.1.8
created_at2025-08-06 18:27:34.209283+00
updated_at2025-08-22 04:36:50.01482+00
descriptionAssert that strings equal easily updatable snapshot files. Show nice colored diffs if not.
homepagehttps://github.com/Enselic/snapshot-testing
repositoryhttps://github.com/Enselic/snapshot-testing
max_upload_size
id1784174
size10,867
Martin Nordholts (Enselic)

documentation

https://docs.rs/snapshot-testing

README

snapshot-testing

Assert that strings equal easily updatable snapshot files. Show nice colored diffs if not.

Usage Example

/// Regression test for `impl Display` of a complex type.
#[test]
fn test_display_of_some_type() {
    let value = ... // produce a value somehow

    snapshot_testing::assert_eq_or_update(
        value.to_string(),
        "./tests/snapshots/display-impl.txt",
    );
}
# Create (or update) the snapshot file
UPDATE_SNAPSHOTS=yes cargo test

# Ensure the Display impl is not accidentally changed
cargo test

Diffing Engine

We use the excellent insta diffing engine without suffering from Issue #425: GitHub syntax highlights insta snapshots like Jest Snapshots which unfortunately makes diffs very hard to read.

Audit the Code

This crate is very small and easily audited with the following command 1:

curl -H "User-Agent: $USER at $HOST" \
     -L https://crates.io/api/v1/crates/snapshot-testing/0.1.8/download |
tar --extract --gzip --to-stdout |
less

Footnotes

  1. Please also see crates.io Data Access Policy.

Commit count: 22

cargo fmt