All notable changes to insta and cargo-insta are documented here.
cargo insta test
not to report test failures.needless_raw_string_hashes
clippy lint on inline snapshots. (#390)input_file
not to be written into the snapshots. (#386)--accept
even if a test outside insta fails. (#358)#[must_use]
.--color=...
to libtest to propagate color choices in more situations. (#375)--exclude
option to cargo insta test
. (#360)color
option from a CARGO_TERM_COLOR
environment variable (#361)allow_duplicates!
to enable multiple assertions for a single snapshot. (#346)rustfmt
use unix newlines.glob!
to set a different base path. (#347)rounded_redaction
to truncate floating point values. (#350)cargo insta test
now correctly detects CI environments like cargo test
does. In that case it will by fail rather than create snapshot update files. (#345)cargo insta test --check
to force check runs. (#345)glob!
optional to better support WASI.review.warn_undiscovered
config key to false
a warning is never printed. (#334)--include-hidden
flag (#331)review.include_ignored
(#330).config/insta.yaml
) to change the behavior of insta and cargo-insta. (#322)--no-ignore
to --include-ignored
.--include-hidden
to instruct insta to also walk into hidden paths.--unreferenced
option to cargo-insta test
which allows fine tuning of what should happen with unreferenced files. It's now possible to ignore (default), warn, reject or delete unreferenced snapshots. (#328)--target
option to cargo insta test
. (#309)foo/*/*.txt
without creating conflicts. (#310)cargo insta test
. (#305)cargo insta test
.cargo insta show
command to render a snapshot.cargo insta
now supports nextest as test runner. (#285)glob!
macro now defers failures by default. (#284)backtrace
feature.serialization
feature.assert_json_snapshot!
and assert_yaml_snapshot!
now require the json
and yaml
feature respectively.INSTA_GLOB_FILTER
to skip over tests expanded from a glob. (#274)#[allow(unused)]
in the macro. (#271)Settings::bind
now can return a result.bind_to_scope
.serde
dependency is now optional. While still enabled by default users need to opt into yaml
and json
features explicitly to regain support for it. To avoid the default serde
dependency the default features just need to be disabled. (#255)serialization
features.backtrace
feature.Settings::bind_to_thread
.Breaking Changes / Upgrading: If you are upgrading to serde 1.18.0 you will receive deprecating warnings if you are using the assert_yaml_snapshot!
and assert_json_snapshot!
macros. These macros will continue to function in the future but they will require explicit opting into the yaml
and json
features. To silence the warning add them to your insta
dependency. Additionally the backtrace
feature was deprecated. It is no longer needed so just remove it.
cargo-insta
where sometimes accepting inline snapshots would crash with an out of bounds panic.filters
feature. (#245)with_settings!
macro now inherits the former settings rather than resetting. (#249)Settings::bind_to_scope
and deprecated Settings::bind_to_thread
. (#250)minimal-versions
builds.--no-quiet
/-Q
flag to cargo insta test
to suppress the quiet flag. This works around limitations with custom test harnesses such as cucumber.with_settings!
. It‘s now a perfect match to the settings object’s setter methods.description
and info
to snapshots. (#239)omit_expression
setting. (#239)"foo\n"
. (#225)cargo insta test
now returns non zero status code when snapshots are left for review. (#222)cargo insta test
. (#223)assertion_line
is no longer retained in snapshots. (#218)sorted_redaction
and Settings::sort_selector
). (#212)Upgrade Notes:
Insta used to detect the current test name by using the current thread name. This appeared to work well but unfortunately ran into various limitations. In particular in some cases the thread name was truncated, missing or did not point to the current test name. To better support different platforms and situations insta now uses the function name instead.
This however changes behavior. In particular if you are using a helper function to assert, a different snapshot name will now be used. You can work around this issue by using a helper macro instead or to explicitly pass a snapshot name in such situations.
once_cell
. (#208)cargo-insta
now correctly handles the package (-p
) argument on test
when deleting unreferenced snapshots. (#201)cargo-insta
. (#191)cargo test
. (#183)Box::leak
. (#185)INSTA_WORKSPACE_ROOT
is set, the value is used as the manifest directory rather than whatever CARGO_MANIFEST_DIR
was set to at compile time. (#180)pending-snapshots
parameter to cargo-insta
.cargo-insta
now honors ignore files. This can be overridden with --no-ignore
.cargo-insta
now supports the vscode extension.--delete-unreferenced-snapshots
parameter to cargo-insta
.globset
crate for the glob
feature.INSTA_UPDATE
is set to always
or unseen
it won't fail on execution.Content
.INSTA_SNAPSHOT_REFERENCES_FILE
environment variable to support deletions of unreferenced snapshot files. (#136)prepend_module_to_snapshot
flag to disable prepending of module names to snapshot files. (#133)console
dependency optional. The colors
feature can be disabled now which disables colored output.Settings::bind_async
when the async
feature is enabled. (#121)console
dependency to 0.11. (#124)glob!
. (#123)cargo-insta
from workspace and add Cargo.lock
. (#116)glob
support. (#112)MetaData
fields internal. (#111)INSTA_OUTPUT
envvar). (#103)console
(lowers total dependency count)cargo insta
in help pages.INSTA_UPDATE=unseen
to write out unseen snapshots without review (#96)backtrace
feature which adds support for test name (and thus snapshot name) recovery from the backtrace if rust-test is not used in concurrent mode (#94, #98)redactions
).ron
).creator
and created
field from snapshot metadata._matches
suffix from all macros.--accept
option to cargo insta test
--force-update-snapshots
option to cargo insta test
--jobs
and --release
argument to cargo insta test
.To upgrade to the new insta macros and snapshot formats you can use fastmod
and cargo-insta
together:
$ cargo install fastmod $ cargo install cargo-insta $ fastmod '\bassert_([a-z]+_snapshot)_matches!' 'assert_${`}!' -e rs --accept-all $ cargo insta test --all --force-update-snapshots --accept