Skip to content

A snapshot testing library for rust

License

Notifications You must be signed in to change notification settings

dtolnay-contrib/insta

 
 

Repository files navigation

insta: a snapshot testing library for Rust

Build Status Crates.io License Documentation

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 one 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.

License and Links

About

A snapshot testing library for rust

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Rust 99.4%
  • Other 0.6%