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 serialised 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 serialised 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 also7
Hand-picked in the note itself — the neighbours worth reading next.
Component Story
An isolated rendered instance of a component, usable as documentation, a workbench, and a test.
Testing & Verification15 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 & Tooling27 connections
Regression
A previously working behaviour that a change has broken.
Method16 connections
Responsive Breakpoint
A viewport width at which a layout changes, and the assumptions that come with it.
Design & Interface7 connections
Test Fixture
The prepared data or state a test runs against.
Testing & Verification12 connections
Stacking Context
The nested coordinate system that decides what paints above what, and why z-index often does nothing.
Design & Interface12 connections
Related2
Nearby in the graph rather than deliberately chosen. Looser, sometimes surprising.
Linked from8
Notes elsewhere in the wiki that reach for this one.
- 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.
- 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 behaviour that a change has broken.
- Responsive BreakpointDesign & Interface
A viewport width at which a layout changes, and the assumptions that come with it.
- 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.