Skip to main content

assert_buffer_snapshot

Function assert_buffer_snapshot 

Source
pub fn assert_buffer_snapshot(
    name: &str,
    buf: &Buffer,
    base_dir: &str,
    mode: MatchMode,
)
Expand description

Assert that a buffer’s text representation matches a stored snapshot.

§Arguments

  • name – Snapshot identifier (used as the .snap filename).
  • buf – The buffer to compare.
  • base_dir – Root directory for snapshot storage (use env!("CARGO_MANIFEST_DIR")).
  • mode – How to compare the text (exact, trim trailing, or fuzzy).

§Panics

  • If the snapshot file does not exist and BLESS=1 is not set.
  • If the buffer output does not match the stored snapshot.

§Updating Snapshots

Set BLESS=1 to write the current buffer output as the new snapshot:

BLESS=1 cargo test