Visual Regression Testing Guide for Web and Mobile UIs
A practical visual regression testing guide: how screenshot comparison works, what to cover, how to cut false positives and where to run it in CI.
Flaky tests erode trust in CI and slow every release. Learn the common causes, how to find them, and a practical policy for fixing flaky automated tests.
A flaky test is one that passes and fails on the same code without any change. It is one of the most corrosive problems in a delivery pipeline, because it teaches the team to ignore red builds. Once developers start saying “just re-run it”, a real regression can slip through unnoticed.
This guide explains why tests become flaky, how to find them, and a simple policy that keeps an automated suite trustworthy, which matters even more when development and QA are split across time zones.
Most flakiness comes from a small set of patterns.
| Cause | Typical symptom | Usual fix |
|---|---|---|
| Timing and async waits | Passes locally, fails in CI | Wait for a condition or event, not a fixed sleep |
| Shared or leftover test data | Fails only when run after another test | Isolate data per test and clean up reliably |
| Test order dependence | Passes alone, fails in the full suite | Make each test set up its own state |
| Unstable environments | Random timeouts or connection errors | Use stable, dedicated test environments or containers |
| External services | Fails when a third party is slow or down | Stub or mock external calls at the boundary |
| Time and date logic | Fails near midnight, month end or across time zones | Inject a controllable clock |
| Brittle UI selectors | Fails after small front-end changes | Use stable test identifiers rather than layout-based selectors |
| Resource contention | Fails under parallel runs | Avoid shared ports, files and accounts |
Fixed sleeps are the classic trap. A two-second pause is too long on a fast machine and too short on a busy CI runner. Modern tools such as Playwright and Cypress include auto-waiting, but you still need to assert on the right condition: wait for the element to be visible, the network call to finish, or the state to change.
Tests that depend on records created by earlier tests will eventually fail when the order changes or tests run in parallel. Each test should create what it needs, use unique identifiers, and not assume an empty or pre-seeded database unless that state is explicitly reset.
You cannot fix what you cannot see. A few practical techniques:
Tooling helps, but policy is what keeps a suite healthy. A workable approach:
Use this when reviewing new automated tests:
Flaky tests are easy to ignore when the people writing tests and the people shipping code are in different places. Make reliability an explicit part of the engagement: agree the flake policy in your working agreement, share the CI dashboard with everyone, and review the slowest and least reliable tests in a regular retrospective. Our guides on test automation strategy and regression testing cover how to decide what to automate in the first place.
If your pipeline has stopped being trusted, AkMo Technologies can audit your suite, stabilise the unreliable tests and set up reporting so problems stay visible. See our software testing services or get in touch to talk through your setup.
A practical visual regression testing guide: how screenshot comparison works, what to cover, how to cut false positives and where to run it in CI.
Contract testing explained for product teams: how consumer-driven contracts catch API breaking changes early and keep mobile, web and backend teams releasing safely.
A practical cross-browser testing guide: choose which browsers to support, automate checks, catch layout and API differences, and release with confidence.
Tell us about your platform, your product idea or the systems you want to modernise. Someone from our Chennai engineering team will get back to you personally.