Guide11 min read

Flaky regression tests: Why they destroy your QA and how to stabilize them

Flaky (unstable) regression tests destroy your team's confidence. Discover why they happen and concrete strategies to stabilize them for good.

Contents
  1. Why visual tests are particularly vulnerable to instability
  2. The four main causes of flaky visual tests
  3. The real cost of flaky tests
  4. Stabilization strategies that work
  5. No-code visual testing as a solution to the maintenance problem
  6. When to delete a flaky test
  7. FAQ

A flaky test (or unstable test) is a test that produces different results (pass or fail) for the same code and the same configuration, without any modification having been made to the system under test.

A flaky visual test is worse than no test at all. A missing test costs nothing day to day: it does not block your pipeline, does not consume your team's time and does not destroy trust in your testing infrastructure. A flaky test does all of that, every day, and it does so insidiously, because every false failure looks just enough like a real one to demand an investigation.

According to Google's data on its own tests, about 1.5% of their tests are flaky at any given time, yet these tests consume a disproportionate share of engineering time. If Google has not eliminated the problem, it is because the question is not trivial. And in the specific field of visual testing, the problem is amplified by the very nature of what is being compared.

The essentials on one page, definition, no-code automation, tool selection grid: Automated regression testing, no code.

Why visual tests are particularly vulnerable to instability

Automated visual testing introduces a layer of non-determinism that unit or functional tests do not know. A unit test checks that a function returns the right value. A functional test checks that a button triggers the right action. These results are binary and deterministic: the function returns 42 or it does not, the button navigates to the right page or it does not.

A visual test, on the other hand, checks that the rendering of your interface matches a reference image. And the rendering of a web page is the result of a chain of complex processes, each introducing its own variability: HTML parsing, CSS application, JavaScript execution, loading of external resources, layout calculation, rasterization, compositing. Each step depends on factors that vary from one run to the next.

A functional test that checks that the "Add to cart" button works is insensitive to the fact that the button moved 0.3 pixel to the right. A visual test detects it. And this detection is sometimes a true positive (the button moved because of a CSS bug), sometimes meaningless rendering noise. It is exactly this ambiguity that makes visual tests flaky.

The four main causes of flaky visual tests

Timing: the problem you cannot ignore

The web is asynchronous by nature. When you ask the browser to capture a screenshot, is the page really ready? The answer is almost always: it depends.

Loading a web page is not a single event, it is a cascade of events. The HTML is parsed, the CSS is applied, scripts are executed, images load, web fonts apply, API requests return data, components render. Each step has a variable duration. An API request that usually takes 50 ms can take 300 if the server is under load. An image that loads in 100 ms can take 2 seconds if the network is slow.

The classic strategy is to wait for the page to be "ready": the DOMContentLoaded event, the load event, or the absence of network activity. But none of these signals guarantees that the visual rendering is complete. The load event fires when the initial resources are loaded, but components rendered client-side via JavaScript can keep loading well afterward. The absence of network activity does not mean all elements are painted: the browser may still be calculating the layout or rasterizing complex elements.

Result: your screenshot sometimes captures a complete page, sometimes a page still rendering. The same test passes on Monday and fails on Tuesday, for no reason related to your code.

Animations: motion in a static medium

A screenshot is a still image. An animation is a continuous change. The two are fundamentally incompatible for automated comparison. We detailed the neutralization strategies in our guide on CSS animations and false positives in visual testing, but here is the essence.

If your page contains a 300 ms animation that starts on load, the exact moment the screenshot is captured relative to the start of this animation varies from one run to the next. At 100 ms, the element is a third of the way through its animation. At 200 ms, it is two thirds of the way. Both screenshots are "correct" (they faithfully reflect the state of the page at the time of capture), but they are visually different, and the comparison tool reports a failure.

Infinite animations (spinners, skeleton loaders, progress indicators) are even worse: there is no "stable" moment to capture the screenshot, because the element is in perpetual motion.

Dynamic content: everything that changes without you

The dates and times displayed in your interface change every second. Ads rotate according to algorithms you do not control. Randomly generated avatars are different in every session. Real-time notifications appear unpredictably. Online visitor counters, "new" badges, personalized welcome messages: all this content varies between two test runs.

Every variation is detected as a visual difference. Every difference makes the test fail. And since these variations are not bugs, every failure is a false failure, a flaky result that consumes your time and brings nothing.

Dynamic content is particularly treacherous because it is often spread throughout the page. It is not an isolated element you can easily exclude: it is a date in the header, a counter in the sidebar, a timestamp in every message of a discussion thread.

Network and infrastructure: the variables you do not control

Your test runs in an environment that depends on external resources: API servers, CDNs for images and fonts, third-party services for widgets and analytics. The latency of each of these resources varies from one run to the next.

In a CI/CD pipeline, the problem is amplified. Your CI runner shares resources with other jobs. The available CPU load varies. Memory fluctuates. The network between the runner and your servers takes different routes depending on the time of day. All these factors affect the page's rendering time, and therefore the visual state at the moment of capture.

A test that systematically passes on the developer's machine can fail intermittently in CI, simply because the CI environment is less predictable. It is frustrating, and it is extremely common.

The real cost of flaky tests

The most visible cost is triage time. Every flaky test that fails in CI requires an investigation: someone has to look at the results, compare them manually, decide whether it is a real bug or noise, and rerun the pipeline if needed. At 5 to 15 minutes per investigation, and with several flaky failures a day, the time adds up quickly.

But the most destructive cost is invisible: it is the loss of trust. When a team learns that visual tests fail "all the time" for no reason, it develops an automatic rerun reflex. "The visual test failed? Rerun it, it will pass." This reflex is rational: most of the time, the rerun is enough. But the day the test fails because of a real bug, the reflex is the same: rerun. And the bug goes to production.

This phenomenon has a name in the software reliability literature: the "cry wolf effect", after the fable of the boy who cried wolf. Once established, it is very hard to reverse. Trust lost in a test suite takes months to rebuild, if it is ever rebuilt.

There is also an opportunity cost. The time your team spends managing flaky tests is time it does not spend writing new tests, improving coverage, or fixing real bugs. Flaky tests are not just a problem, they are an active brake on improving your software quality.

Stabilization strategies that work

Control the rendering environment

The first line of defense is to minimize the variability of the environment. Use a headless browser in a controlled container with a fixed resolution, pre-installed fonts, and a deterministic network configuration. This does not solve everything, but it eliminates an entire category of variability.

In practice, this means freezing the browser version, installing all the fonts used by your application in the container, disabling GPU rendering (which introduces non-determinism), and configuring a fixed-size viewport. It is an initial investment, but it pays off quickly.

Neutralize animations

Inject a stylesheet that forces all animations and transitions to a duration of zero. This instantly freezes all animated elements in their final state, eliminating the timing problem. Most visual testing frameworks offer this option, and it should be enabled by default in all your visual tests.

Beware, though: some animations are functional (a carousel that displays content, an accordion that unfolds a section). Disabling them can hide parts of the interface. For these cases, wait for the animation to reach its final state rather than disabling it.

Stabilize dynamic content

For content that changes on every load, you have several options depending on the context.

Dates and times can be frozen by configuring the test environment with a fixed date. Ads and third-party widgets can be disabled in the test environment. API data can be mocked to return constant responses. Generated avatars can be replaced by static images in the test fixtures.

The goal is to create a test environment where the only variable factor is the code of your interface, everything else is controlled.

Wait intelligently

Instead of relying on a fixed delay (waiting 3 seconds after load), use waiting strategies based on the actual state of the page. Wait for critical elements to be visible, images to be loaded, fonts to be applied, network requests to be finished.

Modern browsers and automation tools offer APIs to observe the state of the DOM and the network. Use them to define precise stability conditions rather than arbitrary delays.

Adopt a comparison that tolerates noise

Pixel-by-pixel comparison is the most sensitive to rendering non-determinism. Perceptual algorithms (SSIM, pHash) are more tolerant. The structural approach (comparing the DOM and computed CSS properties rather than pixels) is the most resistant to rendering noise, because it inherently ignores the sub-pixel variations that cause the majority of flaky failures.

No-code visual testing as a solution to the maintenance problem

An often overlooked aspect of the flaky problem is maintenance. Code-based visual tests (Playwright, Cypress, Selenium) require scripts that navigate to the page, interact with elements, and capture the screenshot. These scripts are themselves a source of instability: a CSS selector that no longer finds the element, a click timing that misses its target, an assertion that fails because the text has changed.

No-code tools like Delta-QA eliminate this layer of fragility. You do not write scripts, you configure your tests visually. The tool handles loading, waiting, stabilization, and comparison. When an element changes its selector, the tool adapts without intervention. When the layout evolves, you update the baseline in one click rather than by editing code.

It is a different philosophy: instead of coding fragile tests you must constantly repair, you configure visual checks that the tool maintains for you.

When to delete a flaky test

If a visual test fails intermittently despite all your attempts at stabilization, the most courageous decision, and often the wisest, is to delete it. A flaky test that nobody fixes is a test that actively degrades your pipeline. It trains your team to ignore failures. It creates noise that masks real problems.

Delete it, document why, and replace it with a more targeted check. Sometimes, a functional test that checks that the element is present and correctly positioned via the DOM is more reliable than a screenshot comparison on an unstable component.

The goal is not to have the maximum number of tests, it is to have tests your team trusts.

FAQ

What is the difference between a flaky test and a false positive?

A false positive is a test result that reports a problem that does not exist, a single occurrence is enough. A flaky test is a test that produces inconsistent results from one run to the next for the same code. A flaky test produces false positives intermittently. All flaky tests generate false positives, but not all false positives come from flaky tests, some are systematic.

How do I measure the flakiness rate of my visual tests?

The simplest method is to run the same visual test suite several times in a row without changing the code and count the tests whose result changes between runs. Five consecutive runs are enough to identify the most unstable tests. Divide the number of tests whose result varied by the total number of tests to get your flakiness rate.

Are no-code visual tests less flaky than coded tests?

They eliminate one category of flakiness, the one tied to the test scripts themselves (fragile selectors, navigation timing, state management). But they remain subject to the same browser rendering constraints as coded tests. The main advantage is the reduction of the fragility surface: less code, fewer potential points of failure.

Should failing visual tests be rerun automatically?

Automatic rerun (retry) is a band-aid, not a solution. It hides the flakiness problem instead of solving it. If you must enable retries, limit them to a single rerun and flag the tests that needed a rerun so you can investigate them. A test that only passes on the second try is a flaky test waiting to be fixed.

What is an acceptable flakiness threshold in CI/CD?

Aim for a flakiness rate below 1% of your total test suite. Beyond 3%, the impact on productivity becomes measurable. Beyond 5%, your team almost certainly develops the reflex of systematically rerunning failing pipelines, which means your test suite has lost its credibility as a safety net.

Does Delta-QA help stabilize visual tests?

Delta-QA reduces flakiness at the source: it simulates the human eye and names the elements that have changed. The sub-pixel rendering, antialiasing and timing variations that cause the majority of intermittent failures are natively ignored, because Delta-QA only flags what a person would notice. Combined with the no-code approach that eliminates fragile test scripts, Delta-QA produces reliable and reproducible test results without complex configuration.

Try Delta-QA