Visual regression testing: how to catch layout bugs your functional tests miss

Visual regression testing: how to catch layout bugs your functional tests miss

In short: Visual regression testing takes screenshots of your screens and compares them with an approved version. If something changes, you see exactly where. It catches layout bugs that functional tests miss, like buttons that overlap or a broken mobile view. Start with a few key screens and fixed test data, not with everything.

All your tests are green, and the order button still sits half under the footer. The functional test found the button, clicked it and the order went through. A real person would never have seen it. A functional test checks whether something works, not whether it looks right. Visual regression testing fills that gap. It’s tricky to get right, though, and most teams give up after a month of false alarms.

What is visual regression testing?

Visual regression testing compares how your application looks with how it looked before. The first time, you take a screenshot of a screen and someone approves it. That’s the baseline, the reference picture. On every later test run, the test takes a new screenshot and compares it pixel by pixel with the baseline. If there’s a difference, the test fails and you get an image with the changed areas marked. A person then decides: is this a bug, or a change we meant to make? If it was on purpose, you approve the new screenshot as the new baseline. A regression is something that worked before and doesn’t now. Here it’s something that looked right before and doesn’t now. You don’t need expensive tools for it. Playwright, a widely used free testing tool, can compare screenshots out of the box. Paid services make the comparison smarter and the review easier.

What does a visual test catch that functional tests miss?

A visual test catches everything that works but looks wrong. Functional tests look at the page’s code: does the button exist, can you click it? They don’t see that the button is hidden behind something else or pushed off screen. These are the bugs a visual test does see.

  • A style change that breaks something elsewhere. A developer makes a block’s margin bigger, and three pages further a form slides out of line.
  • Elements on top of each other. A cookie banner or chat button sitting right over the order button.
  • A broken mobile view. On a narrow screen, a table runs off the page.
  • Fonts, icons or images that don’t load. The page still works, but it looks broken.
  • Longer text in another language. The Dutch button label doesn’t fit where the English one did.

What a visual test doesn’t do is judge whether a screen is pleasant to use. It sees that something changed, not whether a user gets it. That stays human work, through exploratory testing and acceptance testing by real users.

Why do visual tests raise so many false alarms?

Visual tests raise lots of false alarms because they see every difference, including ones that don’t matter. A date that’s different every day. A carousel showing another photo. An ad, an animation caught halfway, or a font that renders slightly differently on one machine than on another. After a week of alerts like that, everyone clicks “approve” without looking. Then you’re not testing anything. These are the four things I’d sort out first.

  1. Hide what always changes. Mask dates, ads and personalised blocks in the screenshot. Playwright can do that with a mask.
  2. Use fixed test data. The same products, the same prices, the same user. Our guide to test data management shows how to set that up.
  3. Always run in the same environment. Same browser, same screen size, on the same machine or container. A screenshot from a Mac and one from a Linux server never match exactly.
  4. Turn off animations and allow a small difference. A few pixels off isn’t a bug. Set a small tolerance.

How do you start without drowning in screenshots?

Start small: five to ten key screens at two screen widths, in one browser. Think of the homepage, a product page, the cart, the checkout and the login screen. Those are the screens where a layout bug costs money or trust straight away. Run them every night and after every release. Only expand once your team takes the alerts seriously, because they nearly always mean something.

Also agree on who reviews the differences, and when. A visual test without an owner turns into a pile of outdated screenshots nobody trusts within two months. At e-commerce clients we see long UI test sets slowing down the pipeline. We help them build a maintainable UI suite that runs fast on several devices without duplicate checks. Visual checks fit well into that, as an addition to functional tests and not a replacement. They belong near the top of the test automation pyramid: few of them, but in the places that matter.

A fair trade-off. If you’re in the middle of a redesign and the layout changes every week, wait a bit. You’d mostly be approving new baselines and catching very little. Start once the design has settled.

What does this mean for your team?

For your team, it means a green test report should also mean the application looks right, on the screens that matter. The technology isn’t the hard part. The hard part is the upkeep. Baselines need updating after every intended change, false alarms need clearing, and someone has to really look at the differences. That work is small each time, but it never stops. Without an owner, it’s the first thing to fall behind.

That repetitive work is what we handle with Test Automation as a Service, working alongside your team. For teams that still run their regression tests by hand, we cut that manual work by up to 70%. Your tests run every night, and we keep them reliable. You get a stable test suite your team can trust, one that doesn’t depend on a single person or add to your team’s workload.

A first step for this week: open your three most important screens on your phone and on a laptop. Would you notice if a button moved there tomorrow? If not, you know where your first visual test should go.

Tests that see what your customer sees, every night.

See how TaaS worksTalk to our team

Frequently asked questions

What’s the difference between visual testing and functional testing?

A functional test checks whether something works: can you log in, does the order go through? A visual test checks whether it still looks the same. You need both, because a screen can work and still look broken.

Which tool do you need for visual regression testing?

To start, a free tool like Playwright is enough, because it can compare screenshots. Paid services help with large numbers of screens and make reviewing easier. Choose once you know how many screens you want to test.

How often should visual tests run?

Every night and after every release is a good rhythm. If they run fast enough, they can also run on every change in the pipeline.

Does a visual test replace checking screens by hand?

No. It sees that something changed, but not whether a user can still get things done. Exploratory testing and acceptance testing by users are still needed.