Fix Failing or Flaky Tests

This skill systematically diagnoses and fixes failing or flaky Playwright tests by categorizing the failure into one of four types (timing/async, test isolation, environment, infrastructure) and applying targeted fixes. It reproduces the failure, captures traces, applies the appropriate fix, verifies stability with repeated runs, and suggests prevention measures.

✨ What it does

  • Reproduces failures with targeted commands and burn-in tests.
  • Captures traces for analysis.
  • Categorizes failures into four types using a taxonomy.
  • Applies category-specific fixes (e.g., web-first assertions, test isolation).
  • Verifies fixes with 10 repeated runs.
  • Provides prevention recommendations.

🎯 When to use it

  • When a Playwright test fails intermittently or is flaky.
  • When a test passes locally but fails in CI.
  • When a test fails only when run as part of a suite.
  • When a test fails due to timing or async issues.

🚀 How to use

Trigger: /debug

Trigger by saying 'fix test', 'flaky test', 'test failing', 'debug test', 'test broken', 'test passes sometimes', or 'intermittent failure'. Provide the test file path, test name, and a description of the issue. The skill will guide through reproduction, categorization, fixing, and verification.

Example prompts:

fix test e2e/login.spec.ts "should redirect after login" - fails in CI but passes locally
The checkout test is flaky. Please fix it.

📄 Output: A report with root cause category, applied fix (with diff), verification result (10/10 passes), and prevention recommendation.

📦 Add this skill to Claude Code

# 1. Get the skills repo
git clone --depth 1 https://github.com/alirezarezvani/claude-skills /tmp/claude-skills

# 2. Copy this skill into your project (or ~/.claude/skills for all projects)
mkdir -p .claude/skills
cp -r /tmp/claude-skills/engineering-team/playwright-pro/skills/fix .claude/skills/fix

Skill source: engineering-team/playwright-pro/skills/fix/SKILL.md

⚠️ Good to know

Requires Playwright test environment and access to the test file; assumes the user can run commands and interpret traces.

❓ FAQ

What if the test passes when run alone but fails in the suite?

This indicates a test isolation issue. The skill suggests removing shared mutable state, creating per-test data, and using unique identifiers.

How do I verify the fix?

Run the test with --repeat-each=10; all 10 runs must pass. If any fail, go back to categorization.

What should I do if the test passes locally but fails in CI?

This is an environment issue. The skill recommends matching viewport sizes, accounting for font rendering differences, using Docker to match CI, and checking timezone-dependent assertions.

🤖 Overview, features, install steps and FAQ were generated from the project's SKILL.md on Sep 4, 2026. Always check the original source before running commands.