assert_render_snapshot

Macro assert_render_snapshot 

Source
macro_rules! assert_render_snapshot {
    ($test_harness:expr, $name:expr) => { ... };
}
Expand description

Assert a snapshot of a rendered frame of your app.

This macro takes a test harness and a name, renders the current state of the app, and stores the rendered image to <CRATE-ROOT>/screenshots/<TEST-NAME>.png.

If a screenshot already exists, the rendered value is compared against this screenshot. The assert passes if both are equal; otherwise, a diff file is created. If the test is run again and the new rendered value matches the old screenshot, the diff file is deleted.

If a screenshot doesn’t exist, the assert will fail; the new screenshot is stored as <CRATE-ROOT>/screenshots/<TEST-NAME>.new.png, and must be renamed before the assert will pass.

You can also run tests with the MASONRY_TEST_BLESS flag set to 1 to assume all differences are intended and overwrite all the screenshots with new values.