Snapshot testing inakamata "picha" ya matokeo fulani (kawaida matokeo ya UI component iliyotengenezwa au muundo wa data) na kulinganisha mafanya ya sasa na iyo — akiashiria inaposababa matokeo. Ni muhimu kwa kugundua mabadiliko yasiyo na niyya, lakini ina mipango inayohitajika kuelewa.
Jinsi snapshot testing inavyofanya kazi
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).();
});
