Skip to main content

assert_inline_snapshot

Function assert_inline_snapshot 

Source
pub fn assert_inline_snapshot(
    actual: &str,
    raw: &str,
    location: &InlineLocation,
    mode: SnapshotMode,
) -> Result<(), InlineSnapshotFailure>
Expand description

Compares actual against the inline-snapshot literal raw.

In Compare mode a mismatch is returned as an InlineSnapshotFailure. In Update mode a mismatch is recorded as a pending patch under target/test-better-pending/ (for the test-better-accept binary to apply) and Ok(()) is returned, so UPDATE_SNAPSHOTS=1 runs stay green; the literal in the source is corrected by the accept step, not by the test run.

ยงErrors

Returns InlineSnapshotFailure when the value does not match the literal and the mode is Compare. A failure to write the pending patch in Update mode is intentionally swallowed: a missing patch is recoverable (rerun), and failing the test would be a worse outcome than a dropped patch.