Snapshot testing cattura uno "snapshot" di un output (comunemente l'output renderizzato di un componente UI o una struttura dati) e lo confronta con esecuzioni future — segnalando quando l'output cambia. È utile per rilevare modifiche non intenzionali, ma ha limitazioni che è importante comprendere.
Come funziona lo 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).();
});
