snapshot-testing 0.1.3

Assert that a multi-line string equals the contents of an easily updatable snapshot file. Print a nice colored diff if not.
Documentation

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 same excellent diffing engine that insta is using. While insta unfortunately suffers from Issue #425: GitHub syntax highlights insta snapshots like Jest Snapshots which makes diffs very hard to read, we allow custom snapshot file extensions and avoid that bug.

Force Colors in CI

Set the env var CLICOLOR_FORCE=1 to get colors in CI logs.

Audit the Code

This crate is 40 lines of code. Audit with the following one-liner, but make sure you follow to the crates.io Data Access Policy:

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