Skip to main content

assert_snapshot

Function assert_snapshot 

Source
pub fn assert_snapshot(
    module_path: &str,
    name: &str,
    actual: &str,
) -> Result<(), SnapshotFailure>
Expand description

Compares actual against the snapshot for module_path/name, with the snapshot directory resolved as tests/snapshots under the current working directory and the mode read from UPDATE_SNAPSHOTS.

cargo test runs a test binary with its working directory set to the package root, so tests/snapshots lands in the package being tested. This is the entry point check!(value).matches_snapshot("name") calls; reach for assert_snapshot_in when the directory or mode must be explicit.

ยงErrors

Returns SnapshotFailure when the snapshot does not match, does not exist (and UPDATE_SNAPSHOTS is unset), or an I/O operation fails (including failing to resolve the current directory).