Cargo Insta

Cargo Insta is the companion command line tool to assist with snapshot reviewing. It's not necessary for working with regular snapshots but it's required when working with inline snapshots.

Installation

Cargo Insta can be installed with cargo if you haven't yet:

cargo install cargo-insta

You can also update it this way. After installation it becomes available as cargo insta.

Commands

Cargo Insta comes with a few different commands.

Common Options

review

Review is the most important command as it can be used to review all pending snapshots. Pending snapshots are snapshots that changed from the stored reference during a test run.

It scans for all non ignored snapshots (optionally filtered down to individual snapshots with --snapshot) and then walks you through all of them. For each snapshot change a diff is shown. To accept a snapshot change press a, to reject r and to skip for now use s.

screenshot of cargo-insta review

When you skip the new snapshot file will be left behind.

accept

This operates exactly like review but instead of an interactive review all snapshot changes will be accepted.

reject

This operates exactly like review but instead of an interactive review all snapshot changes will be rejected.

pending-snapshots

This command returns a list of all snapshots that need reviewing. This is useful when you want to provide editor integrations for insta. For instance this is how the VS Code extension shows the list of pending snapshots.

When JSON output is used the old and new contents of inline snapshots are also returned.

Options:

test

The test command lets you execute all tests (similar to cargo test) but forces all snapshot tests to pass so that they are collected. It accepts the same arguments as the normal cargo test command.

Options:

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