Snapshot Test - CI/CD用語集の定義
snapshot testとは、初回実行時にコードの出力(レンダリングされたコンポーネント、シリアライズされたオブジェクト)を保存ファイルに記録し、その後の実行で出力が保存済みのsnapshotと一致しなくなった場合に失敗するテストです。
仕組み
Jestのようなframeworkは__snapshots__ファイルを書き込みます。変更があるとテストは失敗しdiffを表示します。変更が意図的であればjest -uでsnapshotを更新します。
落とし穴
snapshotは中身を読まずに承認してしまいがちです。巨大なsnapshotを読まずに更新するレビュアーはテストを無意味にしてしまうため、snapshotは小さく意図的に保ちましょう。
関連ガイド
Property-Based Test - CI/CD Glossary DefinitionProperty-Based Test: A property-based test checks that a property holds for many automatically generated inpu…
Smoke Test - CI/CD Glossary DefinitionSmoke Test: A smoke test is a small, fast check that verifies the most critical paths work at all, run right…
Mutation Score - CI/CD Glossary DefinitionMutation Score: A mutation score is the percentage of injected code mutations (deliberate bugs) that a test s…