Snapshot testing किसी output (आमतौर पर एक UI component के rendered output या एक data structure) का "snapshot" capture करती है और भविष्य के runs की उसके विरुद्ध तुलना करती है — flag करती है जब output बदलता है। यह unintended changes का पता लगाने के लिए उपयोगी है, लेकिन इसकी limitations को समझना आवश्यक है।
Snapshot testing कैसे काम करती है
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).();
});
