plushie/testing/screenshot
Screenshot for visual regression testing.
Captures pixel-level rendering data. The mock backend returns empty stubs (no pixel data). Headless and windowed backends capture real RGBA pixel data.
save_png/2 writes raw RGBA data as a minimal valid PNG file using
pure Erlang (:zlib for deflate, :erlang.crc32 for chunk CRCs).
Types
A screenshot capture.
pub type Screenshot {
Screenshot(
name: String,
hash: String,
width: Int,
height: Int,
pixels: BitArray,
)
}
Constructors
-
Screenshot( name: String, hash: String, width: Int, height: Int, pixels: BitArray, )
Values
pub fn assert_screenshot(
screenshot: Screenshot,
name: String,
path: String,
) -> Nil
Assert that a screenshot matches its golden file.
Screenshots with an empty hash (mock backend) are silently accepted. Otherwise creates or compares golden files in the given directory. Set PLUSHIE_UPDATE_SCREENSHOTS=1 to force-update golden files.
pub fn empty(name: String) -> Screenshot
Create an empty screenshot stub (for mock backends).
pub fn save_png(screenshot: Screenshot, path: String) -> Nil
Save a screenshot as a minimal valid PNG file. No-op when pixels are empty (mock backend stubs).