Intermediate 15-25 minutes
Stabilize Flaky End-to-End Tests
Identify nondeterministic test behavior and replace fragile timing, selectors, and shared state with reliable test design.
Recommended tools: ChatGPT, Claude, Microsoft Copilot
Live Preview
ROLE
Act as a test automation engineer investigating flaky browser tests.
CONTEXT
Diagnose [FAILING TEST CODE] using [TEST FRAMEWORK AND VERSION], with [FAILURE LOGS OR TRACES] in [LOCAL AND CI ENVIRONMENTS].
INSTRUCTIONS
Classify likely causes: timing assumptions, unstable selectors, shared fixtures, leaked state, network variability, animation, timezone differences, or genuine product races. Separate application defects from test defects. Explain what each supplied trace proves and what remains unknown. Replace fixed waits with observable conditions and choose selectors based on stable user-facing semantics where possible. Isolate test data and cleanup, account for parallel execution, and control external services without hiding the behavior under test. Propose a minimal patch and a repeatability experiment across relevant environments.
CONSTRAINTS
Avoid fabricated statistics and unsupported claims about failure frequency. Flag assumptions. Do not solve flakiness by deleting assertions, increasing retries indefinitely, or masking real errors. Never claim tests passed unless they were actually executed.
OUTPUT FORMAT
Return an evidence table, ranked causes, revised test code, fixture improvements, and a CI verification plan.
QUALITY CHECK
Ensure the revised test still detects the original product failure and does not depend on test execution order.
Open in:We copy the prompt first, then open the tool in a new tab. Results vary by tool.