A flaky automated test blocks a merge, and the team wants to just turn it off. What do you do?
A flaky test that blocks a merge is neither silently disabled nor cured with retries: it is put into quarantine. It leaves the merge gate but stays in the repository, runs separately without blocking, and has an owner, a ticket and a deadline. The cause is sought from the trace: the test, data or environment, or a real race in the product. Meanwhile the scenario is checked manually.
QA Fundamentals · Situational questions
A flaky test blocks the merge at 17:40 and everybody says "turn it off". Is that fine?
The card payment test fails once in five runs. The pipeline is red, the merge is stuck, somebody is already hitting "rerun", and somebody writes in the chat: "let's skip it and sort it out later". Both options are familiar and both have a price. A rerun teaches the team to ignore red, and a silent skip takes coverage away and often stays forever. This lesson is about when disabling a test is acceptable, what must accompany it, and how to tell a bad test from a real bug.
How it works and why. A flaky test sometimes passes and sometimes fails on the same code and environment. There are three groups of causes. The test itself: wrong expectations, order dependence, shared data. The environment and data: other runs on the same account, an unstable dependency, a slow environment. The product: a real race or a rare error that the test catches by chance. The last group is the most dangerous, because "turning off a flaky test" means turning off a signal about a real bug.
Blocking a merge with an unstable test is harmful, because red stops being taken seriously. Disabling it without a record is just as harmful, because coverage disappears unnoticed. So the acceptable compromise is quarantine: the test leaves the merge gate but stays in the repository, keeps running separately without blocking, and has an owner, a ticket and a deadline recorded for it. Then the temporary step has an end and visible bookkeeping.
A silent skip versus quarantine
"Comment it out and move on"
No ticket, no owner, no deadline. The coverage is gone, nobody knows why, and half a year later nobody remembers the test.
Quarantine with an owner
The test is outside the gate but runs separately, and the ticket has a cause and a date. The failure rate is visible and the scenario is checked manually.
Example: what quarantine looks like in code and in CI. The test is tagged and linked to a ticket:
// FLAKY-214 · owner: Anna · fix or delete by 2026-12-04
test(
'pays by card',
{ tag: '@quarantine' },
async ({ page }) => {
await page.goto('/checkout');
await page.getByRole('button', { name: 'Pay' }).click();
await expect(page.getByText('Payment accepted')).toBeVisible();
},
);
And the pipeline separates two jobs:
# merge gate: quarantine is excluded
npx playwright test --grep-invert @quarantine
# a separate NON-blocking job: we collect failure statistics
npx playwright test --grep @quarantine
# estimate the failure rate: 30 runs without retries
npx playwright test checkout.spec.ts --repeat-each=30 --retries=0
How to read it. The merge gate no longer depends on the unstable test, but a separate job shows every day whether it fails and how often. Retries are not the way out here: in Playwright a test that passed only on a retry is marked as flaky in the report, and that is exactly the signal you need, not one to hide. The third command estimates the rate: if 6 of 30 runs without retries fail, it is a systemic problem, and if one fails you need more data. For the cause, look at the failure trace: was there a request with an error from the API (then it is the product), was the element not ready yet (then the wait in the test), was the data already used by another test (then isolation). While the cause is being found, the scenario is checked manually for every release so that the coverage does not vanish.
Limits and alternatives. Sometimes the fix takes an hour, and then it is faster to do it than to set up quarantine. Teams agree on a time limit: if the cause is not found in two hours, the test goes to quarantine. If the value of the test is low or the scenario is better checked at the API level, it is deleted, not left to rot. Quarantine has a budget: the number of tests and their age are tracked, and if the list grows, the suite loses value. Retries at the CI level are acceptable for infrastructure noise, but they do not replace investigation, because they hide the failure rate.
Common mistakes.
- Raising retries to five and considering the problem solved: the test is "green", but the instability, which could be a bug, remains.
- Disabling a test without a ticket and a deadline: "temporary" becomes "forever".
- Assuming a flaky test is always the test's fault: part of such failures are races in the product.
- Not checking the scenario manually during quarantine: the release goes out without coverage of a key feature.
- Not watching the number of tests in quarantine: the suite gradually stops guaranteeing anything.
Check yourself
A test fails in about one run out of twenty at the "Pay" step. The trace shows that the first payment request got a 409 response and the repeated one got 200. What can this mean, and is it enough to just put the test in quarantine?
Answer
It looks like a race in the product: a double submit or a duplicate check on the backend. The test most likely just catches it by chance. Quarantine is not enough: file a bug with the trace and keep quarantine as a temporary step until the developer fixes it.
Why does "increase retries" not solve the problem of a flaky test even though the pipeline turns green?
Answer
Because retries hide the failure rate: a test may fail in every third run and the gate will not show it. The instability remains, the run time grows, and a real bug in the product that the test caught by chance stays unnoticed. Retries soften noise, they do not investigate the cause.