- Home
- Skills
- Testing & Debugging
- Flaky test detector
Works with the AI Agents you already use
Flaky test detector
Detect, analyze, and fix flaky tests and intermittent CI failures across Jest, Playwright, Pytest, and Cypress.
$5
Flaky test detector
Example session with this skill installed
My Playwright test for the login flow fails about 20% of the time in CI with a timeout, but passes locally. Here is the code: await page.goto('/login'); await page.waitForTimeout(2000);
- Read your context and instructions
- Compiled the flaky test detector
I have analyzed the login flow test. The intermittent failure is caused by a hardcoded sleep that doesn't account for varying CI network latency.
Flaky Test Analysis
Test / File: login-flow.spec.ts
Framework: Playwright
Likely Root Cause Category: Timing / race conditions
Confidence: High
Root Cause Explanation
The test uses a fixed 2000ms timeout to wait for the page to load. In CI environments, resource contention or network latency often exceeds this window, causing the test to attempt interactions before the elements are ready.
Evidence / Smells Found
- Use of
page.waitForTimeout(2000)which is a non-deterministic wait strategy. - Discrepancy between local execution speed and CI runner performance.
Recommended Fix
Replace the fixed sleep with a web-first assertion that utilizes Playwright's auto-waiting capabilities.
Before:
await page.goto('/login');
await page.waitForTimeout(2000);
await page.fill('#username', 'testuser');
After:
await page.goto('/login');
// Auto-waits for the element to be visible and actionable
await page.locator('#username').fill('testuser');
// Or explicitly wait for a specific state if needed
await expect(page.locator('#username')).toBeVisible();
Additional Stabilization Tips
- Use
page.waitForURL()after navigation if the login redirects. - Check if your CI runners have sufficient CPU/Memory to handle browser contexts.
- Increase the global action timeout in
playwright.config.tsinstead of adding local sleeps.
Prevention Checklist
- Replace all
waitForTimeoutcalls with locator-based assertions. - Ensure
awaitis used on all asynchronous Playwright actions. - Use
test.slow()for naturally long-running integration paths.
Next steps
- Apply the locator-based fix to the login spec.
- Run the test in a loop locally using
--repeat-each 10to verify stability. - Check the Playwright trace file if the failure persists to see the exact state at timeout.
Connects securely to your tools. The creator never sees your data.
About this skill
Intermittent test failures waste developer time and degrade CI/CD reliability. This skill identifies the root causes of non-deterministic behavior in your test suite, from race conditions to shared mutable state. It analyzes your code and error logs to determine why tests pass locally but fail in pipelines, providing immediate code fixes to stabilize your builds.
What it does
- Root cause identification categorizes flakes into timing issues, network dependencies, or order-dependent failures.
- Code smell detection flags anti-patterns like fixed sleeps, unhandled promises, and resource leaks.
- Automated refactoring provides side-by-side before and after code blocks with framework-specific fixes.
- Confidence scoring ranks the likelihood of the identified cause to help you prioritize investigation.
- Stabilization strategy generates checklists to prevent regression and ensure long-term suite health.
How it works
- Provide a failing test file, a snippet of code, or the CI error logs.
- The skill analyzes the context against common flakiness patterns like async handling or non-deterministic data.
- It generates a structured report including a category-based explanation and a concrete code fix.
Frameworks & tools
Supports major testing frameworks including Jest, Vitest, Playwright, Cypress, and Pytest. It targets issues related to CI environments, browser contexts, and mock management.
Why this beats prompting it yourself
Generic prompts often miss subtle race conditions or framework-specific nuances like Jest's open handles or Playwright's auto-waiting logic. This skill follows a specialized hierarchy of flakiness checks, ensuring you get a production-ready fix rather than generic advice to "add more waits."
Use cases
- Stabilizing a Playwright suite that fails randomly in GitHub Actions.
- Fixing Jest tests that only fail when run in a specific execution order.
- Refactoring hardcoded sleeps into robust, assertion-based waiting logic.
- Resolving memory leaks or open handles that stall test runners.
Known limitations
Requires either the source code or descriptive error logs to function. It cannot diagnose infrastructure-level failures like runner hardware exhaustion.
Find more skills like this on the Claude Skills Marketplace, the Codex Skills Marketplace and the Gemini Skills Marketplace, or browse Claude Skills for Testing & Debugging.
Requires source code or logs to analyze. Scope is limited to test code logic, not CI runner hardware or network infrastructure issues.
How to use
- 1
Connect your agent to the Agensi MCP
Copy the prompt and paste it into Claude, ChatGPT, Cursor or any agent that supports MCP. It sets up the connection for you. Manual setup
- 2
Sign in to Agensi
Your agent shows a sign-in link. Sign in and click Allow.
- 3
Ask for what you need
Your agent loads this skill and uses it on your task. It always asks before buying a skill.
Reviews
No reviews yet
Be one of the first to try it. Every listed skill goes through the trust checks below.
Security scanned
Checked by our 8-point scan before listing
Fresh listing
Recently published to Agensi
Money-back guarantee
Doesn't do what its page promises? You get your money back.
Trust & safety
Security scan
Security scan passed 28 days ago
Permissions
File Scopes
This skill only needs to read test files to analyze them. It does not modify files, run commands, or require network access unless the user explicitly asks the agent to apply the suggested fixes.