Snapshot testing captures a "snapshot" of some output (commonly a UI component's rendered output or a data structure) and compares future runs against it — flagging when the output changes. It's useful for detecting unintended changes, but has limitations to understand.
How snapshot testing works
1. First run → the test RECORDS the output (e.g. a rendered component) as a SNAPSHOT file
2. Later runs → COMPARE the current output to the saved snapshot:
→ MATCHES → pass; DIFFERS → fail (the output changed)
3. If the change is INTENTIONAL → UPDATE the snapshot (review the diff, then accept)
(, {
tree = ().();
(tree).();
});
