Snapshot testing menangkap sebuah "snapshot" dari beberapa output (umumnya output yang dirender dari komponen UI atau struktur data) dan membandingkan run di masa depan terhadapnya — menandai ketika output berubah. Ini berguna untuk mendeteksi perubahan yang tidak disengaja, tetapi memiliki keterbatasan yang perlu dipahami.
Cara snapshot testing bekerja
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).();
});
