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.snapfilename).buf– The buffer to compare.base_dir– Root directory for snapshot storage (useenv!("CARGO_MANIFEST_DIR")).mode– How to compare the text (exact, trim trailing, or fuzzy).
§Panics
- If the snapshot file does not exist and
BLESS=1is 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