QA glossary

What is a flaky test?

A flaky test is an automated test that passes and fails on the same code, with no change to the code or the test. Its result cannot be trusted, so it hides real failures and teaches a team to ignore red builds.

An example from QA practice

A checkout test clicks the Pay button as soon as the page loads. On a fast build machine it passes. When the payment widget loads slowly, the button is not there yet and the test fails. A developer re-runs the pipeline, it goes green, and nobody looks further. Three weeks later a real regression breaks the button, and that failure is re-run away too.

Common causes

Most flakiness traces back to a short list:

  • Timing: fixed waits instead of waiting for a condition, so the test races the page.
  • Shared data: tests that depend on leftovers from other tests or on the order they run in.
  • Outside services: a real network call, a third-party sandbox or a clock the test does not control.
  • Unstable locators: locators tied to generated IDs or to element order that varies between page loads.
  • Load on the runner: parallel jobs competing for the same machine.

What to do with one

Do not hide it behind automatic retries; a retry makes the build green and the cause invisible. Move the test out of the blocking set, give it an owner and a deadline, find the cause, then fix the test or delete it. Flakiness can be reduced and contained, but any suite that drives a browser will see it again, so the working habit is to detect it early and keep it visible.

Common questions

What does a flaky test cost a team?

Each false failure costs an investigation, a re-run and a delay to the merge, and the repeated re-runs teach people to dismiss red builds. Real failures then get the same shrug. Every developer waiting on the pipeline pays the cost daily, which is why a handful of flaky tests can slow a whole team.

How do you find out whether a test is flaky?

Run it repeatedly on the same code and watch the results. A test that passes and fails without any change is flaky. Build history helps too: a test that fails and then passes on a re-run of the same commit is a strong signal. Running tests in a random order can expose hidden dependencies.

Do flaky tests only happen in UI automation?

No, though UI tests suffer most because they depend on timing, rendering and outside services. Unit and API tests can be flaky too, for example when they rely on the current time, random values, shared databases or the order tests run in. Any test with an uncontrolled input can behave differently from run to run.

How BetterQA does it

Flows, our browser test tool, has self-healing: when a locator stops matching because the page was changed on purpose, it finds a replacement and repairs the test, so a real change does not leave a pile of red tests that people learn to ignore. That is a different problem from flakiness: timing, data and ordering problems still need an engineer. Flows exports its tests to Playwright, Cypress or Selenium, so the tests are not locked into Flows.

Related terms

Further readingUsing code smells to fix flaky Cypress tests

Spotting the patterns that make browser tests unreliable.

ServiceTest automation

Automated suites built to be trusted, not just to run.