Courses / Frontend Testing
7. Snapshot testing
Capturing serialized output and comparing it across test runs with Jest snapshots.
JavaScript
Snapshot testing
A test that captures a serialized output once and flags changes by comparing future runs to that saved "snapshot".
"I don't want to hand-check long JSON or rendered output every time something small changes."
Snapshot testing records a string (often serialized UI or object) during a test run and saves it; future runs compare the current serialized output to the saved snapshot and fail if they differ. It's a quick regression check that alerts you when output changes.
"I don't want to hand-check long JSON or rendered output every time something small changes."
Snapshot testing records a string (often serialized UI or object) during a test run and saves it; future runs compare the current serialized output to the saved snapshot and fail if they differ. It's a quick regression check that alerts you when output changes.