Snapshot testing library for Rust
  • Rust 96.3%
  • TypeScript 3.5%
  • Makefile 0.1%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Pierluigi Lenoci c7b98b8d23
Some checks failed
Tests / Test on Latest (push) Has been cancelled
Tests / Test on Latest-1 (push) Has been cancelled
Tests / Test on Latest-2 (push) Has been cancelled
Tests / Run the in-tree version of cargo-insta on ourselves (push) Has been cancelled
Tests / Check on MSRV (push) Has been cancelled
Tests / Test latest deps (push) Has been cancelled
Tests / Build docs (push) Has been cancelled
Tests / clippy (push) Has been cancelled
Tests / Test with minimal version resolution (push) Has been cancelled
Tests / rustfmt (push) Has been cancelled
feat: add strip_ansi_escape_codes setting (#899)
2026-05-02 06:16:10 -07:00
.github Update cargo-dist to 0.30.2 and fix Windows runner (#821) 2025-11-20 11:41:11 -08:00
.vscode New integration test approach (#537) 2024-08-02 11:21:47 +02:00
assets Update changelog 2020-04-14 01:27:49 +02:00
cargo-insta feat: add strip_ansi_escape_codes setting (#899) 2026-05-02 06:16:10 -07:00
insta feat: add strip_ansi_escape_codes setting (#899) 2026-05-02 06:16:10 -07:00
scripts Move insta to folder (#470) 2024-03-28 11:21:21 +01:00
vscode-insta Bump @tootallnate/once and @vscode/test-electron in /vscode-insta (#881) 2026-03-04 16:58:56 -08:00
.gitignore Remove unnecessary Send + Sync bounds from Redaction (#874) 2026-02-04 18:01:12 -08:00
.pre-commit-config.yaml Add pre-commit hook for Rust code formatting (#760) 2025-04-05 17:55:39 -07:00
.typos.toml fix unreferenced not being read from config file (#759) 2025-04-05 17:55:01 -07:00
Cargo.lock Release 1.47.2 (#894) 2026-03-30 13:48:11 -07:00
Cargo.toml Update cargo-dist to 0.30.2 and fix Windows runner (#821) 2025-11-20 11:41:11 -08:00
CHANGELOG.md Release 1.47.2 (#894) 2026-03-30 13:48:11 -07:00
CONTRIBUTING.md Collect insta version in standard cargo metadata call (#655) 2024-10-10 13:11:54 -07:00
LICENSE Added readme and license 2019-01-13 23:29:03 +01:00
Makefile [ISSUE-718] Allow specifying cargo-nextest bin (#721) 2025-02-12 19:30:35 -08:00
README.md Remove incorrect rustc version from readme and build status 2025-03-22 23:17:56 +01:00

insta: a snapshot testing library for Rust

Crates.io License Documentation VSCode Extension

Introduction

Snapshots tests (also sometimes called approval tests) are tests that assert values against a reference value (the snapshot). This is similar to how assert_eq! lets you compare a value against a reference value but unlike simple string assertions, snapshot tests let you test against complex values and come with comprehensive tools to review changes.

Snapshot tests are particularly useful if your reference values are very large or change often.

Example

#[test]
fn test_hello_world() {
    insta::assert_debug_snapshot!(vec![1, 2, 3]);
}

Curious? There is a screencast that shows the entire workflow: watch the insta introduction screencast. Or if you're not into videos, read the 5 minute introduction.

Insta also supports inline snapshots which are stored right in your source file instead of separate files. This is accomplished by the companion cargo-insta tool.

Editor Support

For looking at .snap files there is a vscode extension which can syntax highlight snapshot files, review snapshots and more. It can be installed from the marketplace: view on marketplace.

jump to definition

Diffing

Insta uses similar for all its diffing operations. You can use it independently of insta. You can use the similar-asserts crate to get inline diffs for the standard assert_eq! macro to achieve insta like diffs for regular comparisons:

use similar_asserts::assert_eq;

fn main() {
    let reference = vec![1, 2, 3, 4];
    assert_eq!(reference, (0..4).collect::<Vec<_>>());
}

Sponsor

If you like the project and find it useful you can become a sponsor.