Snapshot-testaus ottaa "tilannekuvan" jostakin tuloksesta (yleensä UI-komponentin renderoidusta tuloksesta tai tietorakenteesta) ja vertaa tulevaisuuden ajoja siihen — ilmoittaa kun tulos muuttuu. Se on hyödyllinen tahattomien muutosten havaitsemiseen, mutta sillä on rajoituksia, jotka on tärkeä ymmärtää.
Snapshot-testauksen toiminta
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).();
});
