The pipeline is green and the release goes live. An hour later, a user reports that the order button on mobile is half hidden behind the footer. Functionally, everything worked. Visually, it did not.
That is not an unusual scenario. It is exactly the kind of bug a classic test suite is blind to, and the reason visual regression testing exists.
Functional tests check behaviour: can a user log in, is an order processed correctly, does the right error message appear? They locate elements through selectors and verify that those elements exist, are visible and respond. Where an element sits exactly, what colour it has or whether it overlaps something else usually falls outside their field of view.
So a button can be perfectly clickable for your test framework while a real user sees it shifted, unreadable or half hidden. These bugs are rarely intentional. A CSS change, a component library update or a new font ripples through to places nobody thought of.
You compare screenshots of your application with an approved reference, the baseline.
Playwright has this built in. A single assertion is enough:
// the first run writes the baseline, every run after that compares against it
import { test, expect } from '@playwright/test';
test('checkout still looks as approved', async ({ page }) => {
await page.goto('/checkout');
await expect(page).toHaveScreenshot('checkout.png', {
maxDiffPixelRatio: 0.01,
animations: 'disabled',
mask: [page.getByTestId('order-date')],
});
});
maxDiffPixelRatio sets how much deviation is acceptable, animations freezes animations and mask covers dynamic areas, such as a date that changes on every run.
Visual tests do not replace your functional tests. They complement them where visual bugs are frequent or costly:
For an internal back-office application that rarely changes its look, the investment is often unnecessary. Start where a visual bug hurts most.
| Tool | Type | Strong at |
|---|---|---|
| Playwright | Open source | Built in via toHaveScreenshot(). Free, you manage baselines in your own repo. |
| Chromatic | SaaS | Component-level visual tests through Storybook, with review per pull request. |
| Percy | SaaS | Pages and components, a review UI and integration with existing test frameworks. |
| Applitools | SaaS | AI-based comparison instead of pixel by pixel, less sensitive to noise. |
The choice depends less on features than on your context. Which framework do you already use? Where do you want to manage baselines? And who reviews the differences, only the test team or designers and developers too? With Playwright you need no extra licence. A SaaS tool mainly pays off when several teams take part in reviews.
Fonts, anti-aliasing and rendering differ per operating system and browser version. A screenshot taken on your laptop rarely matches one from a Linux pipeline pixel for pixel. Always create and compare baselines in the same environment, for example a fixed Docker image.
Dates, counters, ads and animations change on every run. Mask those areas or freeze animations, or your test fails for the wrong reason.
Every baseline is maintenance. A hundred screenshots of nearly identical pages mostly create review work, not extra confidence.
When a visual test fails, it is tempting to simply approve everything again. At that point you are no longer testing anything. Every new baseline deserves a review, just like a code review.
Visual regression testing catches exactly the bugs your functional tests miss. Provided you apply it in a targeted way and take the review process seriously.
We'll review your test approach and tell you honestly where the gains are. And where they aren't.
Book a call