hardening-flaky-e2e-tests

Diagnoses and fixes flaky Playwright e2e tests by replacing race-prone patterns with retry-safe assertions.

2.0k|679|Updated Jun 13, 2024
One-click install
npx skills add https://github.com/Comfy-Org/ComfyUI_frontend --skill hardening-flaky-e2e-tests
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: hardening-flaky-e2e-tests
Source: https://github.com/Comfy-Org/ComfyUI_frontend/tree/main/.claude/skills/hardening-flaky-e2e-tests
Command: npx skills add https://github.com/Comfy-Org/ComfyUI_frontend --skill hardening-flaky-e2e-tests

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Flaky end-to-end tests fail intermittently in CI due to race conditions, tight timeouts, and snapshot-then-assert patterns, eroding trust in the test suite and blocking merges. This Skill provides a systematic workflow to diagnose the root cause of each flake and replace it with a retry-safe alternative.

Core Features & Use Cases

  • CI Evidence Gathering: Pulls Playwright reports from GitHub Actions runs with gh CLI and locates tests marked as flaky, including ones that passed only on retry.
  • Pattern Classification: Matches failing assertions against a table of ten common race-prone patterns such as immediate count checks, tight poll timeouts, and screenshots without readiness waits.
  • Mechanical Transforms: Applies concrete fixes like converting expect(await evaluate()).toBe(x) to expect.poll(), exposing locators for toHaveCount(), removing force: true clicks, and using toPass() for multi-condition settling.
  • Use Case: A CI run shows a spec failing intermittently after a menu click. The Skill identifies the nextFrame-after-click race, replaces it with contextMenu.waitForHidden(), and verifies the fix with --repeat-each 10 before monitoring the next CI run.

Quick Start

Ask the AI to diagnose and fix the flaky Playwright tests reported in the latest CI run for the current branch.

Frequently Asked Questions about hardening-flaky-e2e-tests

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I fix flaky Playwright tests in CI?

Download the Playwright report artifact from the failing GitHub Actions run, find entries with status flaky, and classify each failure against known race patterns. Then replace snapshot-then-assert code with retrying assertions like expect.poll, toHaveCount, or toPass.

How to replace waitForTimeout in Playwright tests?

Replace waitForTimeout with an assertion on the real readiness boundary, such as expect.poll for async values, toHaveCount for locator counts, or waitForHidden after menu clicks. Fixed sleeps hide races instead of resolving them.

Why does my Playwright test pass locally but fail in CI?

CI environments are slower and expose timing races that local runs mask, such as reading state immediately after a mutation or using tight poll timeouts under 2000 ms. Widen timeouts and poll the actual value instead of asserting a single snapshot.

When should I use expect.poll versus toPass in Playwright?

Use expect.poll when asserting a single async value like a graph link count, and toPass when multiple assertions must settle together, such as two node values. Use built-in retrying assertions like toBeVisible or toHaveCount for locator state.

How do I verify a flaky test fix before merging?

Rerun the specific spec with --repeat-each 10, or 20 for a single test case, using the smallest command that exercises the flaky path. Then watch the CI E2E workflow with gh run watch and inspect the new Playwright report artifact.