スナップショットテストは、何らかの出力(一般的にはUIコンポーネントのレンダリング出力またはデータ構造)の「スナップショット」をキャプチャし、将来の実行時にそれと比較することで、出力の変化を検出します。意図しない変更を検出するのに有用ですが、その限界を理解することが重要です。
スナップショットテストの仕組み
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).();
});
