QA GLOSSARY · TERM 6 OF 6
Flaky test
A flaky test is one that passes on some runs and fails on others without any change to the code. People stop trusting it, then stop reading failures, and a real bug slips through. Answers from an AI feature are flaky by nature, which is why llmcheck reports a case that is only sometimes right as flaky.
Why a test turns flaky
- Timing. The test clicks before the page is ready. Fixed pauses ("wait two seconds") are the usual cause: sometimes two seconds is enough and sometimes it is not. Playwright waits for an element to be ready before it acts, which removes most of these.
- Shared state. One test leaves data behind that another depends on, so the result depends on the order they run in.
- Things you do not control. A third-party service, a slow network, a clock, a date, a random number.
- Animations and late content. The check looks while something is still moving.
- A model that answers differently every time. The thing under test is itself not repeatable.
How to catch one
Run it many times. A test that passes once proves little, and a test that fails once may mean nothing. Playwright can repeat a test on purpose, and its report marks a test that failed and then passed on a retry as flaky:
npx playwright test tests/checkout.spec.ts --repeat-each=20Be careful with automatic retries. They turn a red build green, which is useful for keeping a team moving, but a retry that quietly hides a flaky test only moves the problem. Read the report for tests marked flaky and fix the cause.
A different kind: AI answers
A language model gives a different answer to the same question each time, so for an AI feature flakiness is not a rare bug in a test, it is a property of the thing being tested. llmcheck, the open-source tool behind the AI quality service, deals with it in two ways. It asks every question several times, and it requires a pass rate you choose. A case that passes some attempts and fails others is marked flaky even when it clears the bar, so a model that is right four times in five does not hide behind a lenient threshold.
FAIL price-pro 4/5 (flaky)
attempt 3 (How much is the Pro plan?): contains '$19': missing "$19"
answer: 'The Pro plan is $29 a month.'
PASS refund-window 5/5The demo server is a pretend assistant that answers from a script, and the script is imperfect on purpose: it gives a wrong price one time in five. It is only there to give the tool something to run against.
Repeating has a limit. Three or five repeats catch a flaky answer, but they cannot prove that an assistant never leaks its prompt: a leak that happens once in a hundred tries needs a hundred tries.
What to do with a flaky test
- Find the cause, not the symptom. Run it repeatedly, and read what differs between a pass and a fail.
- Fix it at the source: replace fixed pauses with waiting for a condition, make each test create its own data, freeze or mask what changes (see visual regression testing).
- If it cannot be fixed today, take it out of the way with a note and an owner, instead of leaving a test that fails at random and teaches everyone to ignore red.
Questions people ask
Is a test that fails once in a hundred runs flaky?
Yes. A test that fails without a code change is flaky however rarely. At one failure in a hundred runs, a team that runs the suite ten times a day sees a false alarm about every ten days, and that is enough to start the habit of ignoring failures.
Are retries a fix?
No. A retry keeps the build green but leaves the cause. Treat a test that passes only on retry as a bug in the test or the app, and fix it.
Can an AI test ever be reliable?
A test for an AI feature can be reliable as a measurement: asked many times, with a pass rate you decide in advance, it says how often an answer is right. What it cannot do is promise that the model never gives a wrong one.