What visual regression testing is
Visual regression testing takes a screenshot of a page, a component or a screen and compares it with a baseline (the screenshot of the same page or component taken earlier, that someone already looked at and approved). If the two differ by more than a threshold, the test fails and the tool keeps the new screenshot and a diff image that highlights what changed. A human then decides: is it a bug or a change that should become the new baseline.
Each screenshot comes down to three files: baseline, actual, diff. Have a look at the demo below to see how they are used:
What visual regression catches that other tests miss
Let's compare it with other testing types. A unit test checks that a function returns the right value. An end-to-end test checks that clicking "Buy" produces an order. But in our demo case: neither notices that the "Buy" button is now rendered on a white background, overflowing it's parent box. In the same way "standard" test won't catch when a CSS refactor moved the footer under the sidebar or that a font update made every heading wrap onto two lines. That's problematic as assertions see the DOM, but users see pixels.
Visual regression tests are the only automated check that looks at what the user looks at. They are cheap to write (one line per screenshot) and broad (one screenshot might cover everything in the viewport). They catch the class of bugs that is otherwise found by a designer, a customer or nobody.
What it is not
- Not a replacement for functional tests. A screenshot cannot tell you a form submits. Use visual regression as a suplement to e.g. your smoke, E2E tests.
- Not an exact-match check. Browsers render text and anti-aliasing slightly differently between versions and machines. Every serious tool allows a tolerance. Chapter 3 of this guide is about keeping the noise below it.
- Not "snapshot testing" of markup. Jest-style snapshots serialize a component tree to text. They catch changes in markup, not in rendering. The two are often confused because some libraries do both.
- Not necessarily a design review. A baseline is what the app looked like last time, not what the design says it should look like. The test catches unintended change ("regression") whether the intended change is right is still a conversation. There are possibilities to compare your website visually with e.g. Figma designs. But setting it up still comes up with a whole separate set of issues.
The vocabulary
Before we dive deeper into visual regression testing, let's introduce some of the key vocabulary:
| term | meaning |
|---|---|
| baseline / reference / expected | the approved screenshot a new one is compared against |
| actual / current / received | the screenshot taken in this run |
| diff | an image highlighting the pixels that differ |
| threshold | how much difference is tolerated before the test fails; two limits: a color tolerance per pixel (colorThreshold in the manifest) and a maximum share of differing pixels per image (maxDiffRatio) |
| approve / accept / update | make the actual image the new baseline |
| flaky | a comparison that fails without any change to the code |
Different tools use different words, but concepts stay the same. Our proposed manifest-standard uses baseline, actual and diff, so we'll keep using those for the rest of this guide.
Where and when should I use it?
Teams usually start with the pages or components that break most and that nobody notices breaking: marketing pages after a redesign, a design-system's component library, checkout flows, anything with careful typography. One screenshot per component story (Storybook makes setting it up almost free) and one per key page is a common first setup and it already catches most layout regressions.
From there the questions are about logistics: where do baselines live, who approves changes, how do you keep the comparisons stable across machines, and what happens in CI. The next chapters take them in that order.
Further reading
- Regression testing on Wikipedia, for where the term comes from.
- The Test Pyramid by Martin Fowler, on why broad-but-slow tests should be few.
- Visual tests in the Storybook docs, the component-level view.
- Screenshots in the Playwright docs, the page-level view.