plushie/testing/snapshot

Tree snapshot testing.

Captures a JSON representation of the UI tree structure and compares against golden files. On first run, creates the golden file. On subsequent runs, compares and fails on mismatch.

Set PLUSHIE_UPDATE_SNAPSHOTS=1 to force-update golden files.

Values

pub fn assert_tree_snapshot(
  tree: node.Node,
  name: String,
  path: String,
) -> Nil

Assert that a tree matches its golden snapshot file.

If no golden file exists, creates one (first run). If PLUSHIE_UPDATE_SNAPSHOTS=1 is set, updates the golden file. Otherwise compares JSON and panics on mismatch.

pub fn node_to_json(tree: node.Node) -> json.Json

Serialize a Node to deterministic JSON (sorted keys).

Search Document