Visual Regression Testing
Comparing rendered output against a stored baseline to catch unintended visual change.
Visual regression testing captures a rendering — usually a screenshot, sometimes a serialized tree — and compares it against a stored baseline, failing on difference. It catches the large class of visual defects that no assertion describes, and it is the only practical way to verify a refactor that is supposed to change nothing visible.
Snapshot Testing of serialized output is the same idea in text form, and shares the same weakness: a snapshot records what the code did, not what it should do, so a wrong output is happily enshrined by an unthinking update. Reviewing the diff rather than blessing it is the entire discipline.
For pixel comparison the practical problems are all about determinism. Fonts must be loaded, animation disabled, device pixel ratio fixed, and remote images avoided — any of which will otherwise produce differences unrelated to the change. A useful sanity check is to capture the same code twice and confirm the difference is zero; if it is not, the harness is not measuring the code.
Two traps recur. A static server that rewrites URLs can silently serve an error page for every capture, producing a baseline of identically-sized images that look fine in aggregate — check that file sizes vary. And a wrapper applied to some renders and not others produces an offset that fails everything for one reason.
See also8
Snapshot Testing
Comparing a component or output's current rendering against a saved baseline, flagging any difference for a human to accept or reject.
Testing & Verification5 connections
Component Story
An isolated rendered instance of a component, usable as documentation, a workbench, and a test.
Testing & Verification16 connections
Headless Browser
A real browser driven programmatically without a visible window.
Testing & Verification10 connections
Determinism
The property that identical inputs produce identical outputs, and the foundation of caching and verification.
Systems & Tooling56 connections
Regression
A previously working behavior that a change has broken.
Method19 connections
Responsive Breakpoint
A viewport width at which a layout changes, and the assumptions that come with it.
Design & Interface10 connections
Test Fixture
The prepared data or state a test runs against.
Testing & Verification13 connections
Stacking Context
The nested coordinate system that decides what paints above what, and why z-index often does nothing.
Design & Interface13 connections
Related2
Nearby in the graph rather than deliberately chosen. Looser, sometimes surprising.
Linked from10
- Component StoryTesting & Verification
An isolated rendered instance of a component, usable as documentation, a workbench, and a test.
- Flaky TestTesting & Verification
A test that passes and fails on identical input, and the most corrosive thing a suite can contain.
- Golden File TestingTesting & Verification
Comparing an output against a checked-in reference file the whole team agreed was correct, rather than an inline assertion.
- Headless BrowserTesting & Verification
A real browser driven programmatically without a visible window.
- Integration TestTesting & Verification
A test exercising several components together, through real interfaces rather than doubles.
- RegressionMethod
A previously working behavior that a change has broken.
- Responsive BreakpointDesign & Interface
A viewport width at which a layout changes, and the assumptions that come with it.
- Snapshot TestingTesting & Verification
Comparing a component or output's current rendering against a saved baseline, flagging any difference for a human to accept or reject.
- Stacking ContextDesign & Interface
The nested coordinate system that decides what paints above what, and why z-index often does nothing.
- Test FixtureTesting & Verification
The prepared data or state a test runs against.