GuidesZero flaky tests
Triage failed tests on demand
Replace blind CI retries with a quick "why did this fail?" check that shows whether a Playwright failure is new, with replays and optional quarantine.
When an end-to-end test turns a pull request red, the fastest reflex is clicking "Re-run failed jobs". Every blind retry trains the team to treat red checks as noise, hides whether the failure came from this branch or from main, and wastes another CI cycle when a real regression is sitting right in front of you.
Instead of re-running first and asking questions later, add a "why did this fail?" triage step whenever a pull request fails. Using Endform's run history and attempt diffs, you or a coding agent can answer two questions in seconds:
- Is this already failing for everyone else on
mainor other pull requests? If yes, notify an owner, feed it into your weekly flake loop, and move on. (If it is blocking merges right now, you can also add a short-lived quarantine rule.) - Is it isolated to this pull request? If yes, do not mute it. Pull the diverging step, error details, and replay link so the next human or coding agent gets an actionable diagnosis instead of a raw timeout.


Run the triage check (MCP or CLI)
Whether you ask your coding agent in your editor or run the Endform CLI directly, on-demand triage pulls the same context. Switch between MCP and CLI below to inspect how this works on BikeBook's PR #4 (demo/checkout-regression):
I'll pull the failing test runs on this branch, check the same test's 7-day history on main, inspect the failing attempt, and grab a replay link.
samples_query{
"dataset": "test-runs",
"where": "branch = demo/checkout-regression, testRun.outcome = fail",
"period": "24H",
"limit": 10
}analytics_query{
"dataset": "test-runs",
"metric": "pass-rate",
"groupBy": "test",
"where": "branch = main, test.id = <testId>",
"period": "7D"
}test_attempt_inspect{
"testAttemptId": "<testAttemptId>"
}test_attempt_replay{
"testAttemptId": "<testAttemptId>"
}Isolated to PR #4 (100% pass rate on main over the last 7 days, so do not quarantine). In "upgrading to Plus records exactly one payment", clicking Complete Purchase fails because processPayment looks up lowercase "plus" while the pricing form submits "Plus". Ready for a fix with the replay linked.
npx endform@latest npx endform@latest npx endform@latest npx endform@latest Hover or click any highlighted flag to see what it does.
Three habits make triage fast and accurate:
- Group related failures first: If five or more tests failed together with the same upstream
503or preview deployment error, treat them as one environment incident instead of triaging each test separately. - Check
mainbefore touching code: Comparing the failingtest.idagainst a 7-day pass-rate query onbranch = mainimmediately separates a brand-new regression on this PR from a known recurring flake. - Share the replay link:
test_attempt_replay(ornpx endform@latest test-attempt replay <testAttemptId>) returns a shareable replay link for the failing attempt. Whenever a matching passing run is available, Endform pairs the two runs side by side automatically.
Here is a live replay from that BikeBook checkout regression, where Endform automatically paired the failure beside a passing main run. Scrub the frames to see checkout fail as soon as the user clicks Complete Purchase:
Choose the right next step
Once you have the main history and failure details, every red pull request falls into one of three buckets:
| Signal from Endform history | What happened | What to do |
|---|---|---|
Green on main, broken only on this PR | Real regression introduced by this branch | Post the diverging step, error, and replay link on the PR so the author or a coding agent fixes the app. Do not quarantine. |
Green on main, selector or copy mismatch on this PR | Intentional UI or product change broke an older test | Update the test on this branch (or delegate volatile steps with natural-language steps). |
Already failing on main or across other PRs | Shared recurring flake or broken upstream dependency | Notify the owning team and let the weekly flake loop fix the root cause. Optionally add a time-boxed quarantine rule if it is blocking merges. |
Automate triage as a pull request feedback step
Passing pull requests should pay zero extra cost. Wire triage in as a failure-only CI step right after npx endform@latest test so every red run posts a structured diagnosis and replay link automatically.
Here is a GitHub Actions example that gives the coding agent access to the Endform MCP server and runs only when the Endform step fails:
permissions:
contents: read
id-token: write
pull-requests: write
steps:
- name: Run Playwright suite on Endform
id: e2e
run: npx endform@latest test
- name: Triage failed tests
if: ${{ failure() && steps.e2e.outcome == 'failure' }}
uses: anthropics/claude-code-action@v1
env:
ENDFORM_API_KEY: ${{ secrets.ENDFORM_API_KEY }}
with:
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
claude_args: >-
--mcp-config '{"mcpServers":{"endform":{"command":"npx","args":["-y","endform@latest","mcp"]}}}'
--allowedTools "mcp__endform__*"
prompt: |
Endform E2E tests failed on branch "${{ github.head_ref }}"
(PR #${{ github.event.pull_request.number }}).
Use the Endform MCP server to investigate the failures and post
one concise triage comment on this pull request with:
- Whether each failure is isolated to this PR, caused by an
intentional UI change, or already failing on main (include
recent pass rates on main). If 5+ tests failed with the same
upstream error, group them as one environment incident.
- The root cause, diverging step, and error summary for each
distinct failure.
- A replay link for the failing attempt when available.
- A clear recommended next step for the engineer or follow-up
coding agent.
Do not modify code or create quarantine rules automatically.npx endform@latest test authenticates via GitHub OIDC (id-token: write) when the Endform GitHub App is installed, while the Endform MCP server in CI needs an ENDFORM_API_KEY secret (create one with npx endform@latest api-key create --name "GitHub Actions"). Notice that the prompt describes the outcomes you want and lets the agent choose which Endform MCP tools to call.
That gives every reviewer and follow-up coding agent a high-signal comment on the pull request before anyone thinks about hitting re-run:
### Endform E2E Triage: 1 failure (isolated to this PR)
**Test:** `tests/signed-in/checkout.spec.ts`
(*upgrading to Plus records exactly one payment*)
**Main branch (7D):** 100% pass rate (28/28 runs)
**Classification:** PR-only regression (do not quarantine)
**What diverged:**
- Clicking `Complete Purchase` stays on `/pricing/checkout` with an
inline checkout error instead of redirecting to
`/dashboard/team?payment=success`.
- In `lib/payments/actions.ts`, `processPayment` looks up plans with
lowercase `"plus"`, while the pricing form submits `"Plus"`.
**Replay:** [Open the full replay](https://endform.dev/app/demo/failing-checkout-replay?view=full)
**Next step:** Fix the plan-name lookup mismatch on this branch and
re-run `tests/signed-in/checkout.spec.ts`.Start with recommend-only triage comments until your team trusts the classifications. Once the comments are consistently accurate, you can allow the triage agent to create quarantine rules automatically only when all three conditions hold:
- The same test and matching error have already failed on
mainor at least two other pull request branches in the last 24 hours. - The rule is scoped narrowly to the exact
suiteIdandtestId(never a whole suite or whole branch). - The rule sets an explicit
endsAtexpiry (for example, 48 to 72 hours) and areasonlinking to the PR or tracking issue, so it cannot turn into a silent graveyard.
Never auto-quarantine a failure that is green on main and unique to the current pull request.
Quarantine
Quarantine is an optional add-on when a known shared failure is actively blocking unrelated pull requests while someone investigates the root cause.
Quarantine keeps selected tests running while you investigate. When a quarantined test fails, the suite does not fail. Endform still records its results and traces, so you keep collecting evidence and can see when the fix lands.
You need a suite that has run on Endform at least once, so you can pick it.
Create a rule
I'll look up the suite and test IDs from recent runs, then create a scoped quarantine rule with an expiry.
samples_query{
"dataset": "test-runs",
"where": "branch = main, testRun.outcome = fail",
"period": "7D",
"limit": 5
}quarantine_create{
"suiteId": "suite_123",
"testId": "test_456",
"reason": "Tracking flaky checkout test in #412",
"endsAt": "2026-12-01T12:00:00Z"
}Quarantined "checkout times out on retry" in the web suite until 2026-12-01T12:00:00Z. The test will keep running and collecting traces, but its failures will not block merges.
npx endform@latest Hover or click any highlighted flag to see what it does.
- Open your organization's Quarantine page.
- Select Add quarantine rule and choose a Suite.
- Fill in at least one of Test, Project, or Branch.
- Check the matching tests in the preview, then select Create rule.
All filled-in fields must match exactly. Empty fields match any value within the suite, so a rule with only a branch quarantines every test on that branch. Prefer scoping rules to a specific suiteId and testId, writing a clear reason, and setting an endsAt expiry so the rule never outlives the investigation.
Check which tests are quarantined
Let me list the active quarantine rules across your suites.
quarantine_list{
"includeInactive": false
}One active rule: "checkout times out on retry" in the web suite (expires 2026-12-01T12:00:00Z, reason: "Tracking flaky checkout test in #412").
npx endform@latest Hover or click any highlighted flag to see what it does.
- Open your organization's Quarantine page to review active rules, their scope, reason, and expiry.
Remove quarantine once the fix lands
After the owner or your weekly flake loop fixes the test, verify that recent runs pass cleanly and deactivate the rule so the test returns to blocking CI:
npx endform@latest quarantine deactivate <ruleId>For every argument the rules take, see the quarantine reference.
Next steps
Turn recurring and quarantined flakes into permanent weekly app and test fixes.
Test steps as natural languageCut UI-change triage noise at the source with Playwright Intent.
Quarantine referenceInspect every quarantine action, argument, and matching rule across CLI, MCP, and dashboard.
Last updated