Skip to main content

snapshot

Macro snapshot 

Source
macro_rules! snapshot {
    ($name:literal) => { ... };
}
Available on crate feature snapshot only.
Expand description

Name a snapshot baseline, embedding its bytes where there is no filesystem.

Natively this is the name alone and the file is read when the frame is compared, so SNAPSHOT_UPDATE=1 can rewrite it. In a browser the bytes are read out of the repository at compile time and travel inside the wasm binary, resolved relative to the file the macro is invoked from.

The name must be a literal, because it is also the path include_bytes! resolves.

ยงExample

use unlit_wgpu_test_util::snapshot;

let baseline = snapshot!("lit_cube.webp");
assert_eq!(baseline.name(), "lit_cube.webp");