Insta Snapshots

Insta is an enjoyable snapshot testing tool for Rust.

Star Sponsor

Learn More ⇣

Hello Snapshot Testing

Build Status Crates.io License Documentation

Snapshots tests (also sometimes called approval tests) are tests that assert values against a reference value (the snapshot). Think of it as a supercharged version of assert_eq!. It lets you compare a value against a reference value but unlike simple assertions the reference value is managed by insta for you.

What's in the Box?

What Does This Look Like?

Pretty simple. You write a test function where you perform some sort of computation and then use one of the insta provided assertion macros:

#[test]
fn test_simple() {
    insta::assert_yaml_snapshot!(calculate_value());
}

Note that no reference value is provided. Instead the reference value is placed on the first test run in a separate snapshot file. Insta will automatically manage that snapshot for you.

Test Workflow

This is what this process looks like in an actual example:

Learn More

Want to learn more?

Found an issue? You can edit this page on GitHub.