Testowanie za pomocą snapshots przechwytuje "snapshot" pewnego wyjścia (zwykle renderowanego wyjścia komponentu UI lub struktury danych) i porównuje przyszłe uruchomienia z nim — flagując, gdy wyjście się zmienia. Jest przydatne do wykrywania niezamierzonych zmian, ale ma ograniczenia, które należy zrozumieć.
Jak działa testowanie za pomocą snapshots
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).();
});
