Skip to main content

assert_snapshot_in

Function assert_snapshot_in 

Source
pub fn assert_snapshot_in(
    dir: &Path,
    module_path: &str,
    name: &str,
    actual: &str,
    mode: SnapshotMode,
) -> Result<(), SnapshotFailure>
Expand description

Compares actual against (or, in Update mode, writes it to) the snapshot file for module_path/name under dir.

This is the directory-explicit core: assert_snapshot is the wrapper that derives dir from the current working directory. Tests of this crate use assert_snapshot_in against a temporary directory so they need not depend on the process’s working directory or a committed fixture file.

In Compare mode it returns SnapshotFailure on a mismatch or a missing file. In Update mode it creates the directory if needed, writes actual, and returns Ok(()).

§Errors

Returns SnapshotFailure when the snapshot does not match, does not exist (in Compare mode), or an I/O operation fails.