Giter Site home page Giter Site logo

yujong-lee / insta Goto Github PK

View Code? Open in Web Editor NEW

This project forked from mitsuhiko/insta

1.0 1.0 0.0 10.1 MB

A snapshot testing library for rust

Home Page: https://insta.rs

License: Apache License 2.0

Shell 0.16% Rust 91.66% TypeScript 7.83% Makefile 0.35%

insta's Introduction

insta: a snapshot testing library for Rust

Build Status Crates.io License rustc 1.51.0 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.

License and Links

insta's People

Contributors

amilajack avatar arabidopsis avatar byk avatar cad97 avatar cosmichorrordev avatar dependabot[bot] avatar hawkrives avatar johnnymorganz avatar joshmcguigan avatar kianmeng avatar kjeremy avatar loewenheim avatar lpghatguy avatar martinvonz avatar marwes avatar matklad avatar max-sixty avatar michaelmcdonnell avatar mikailbag avatar mitsuhiko avatar mkantor avatar nikstur avatar saks avatar swatinem avatar tim77 avatar untitaker avatar wasabifan avatar zazabe avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.