pw-flaky-debugger
Diagnoses a flaky Playwright test and proposes web-first fixes. Use when an SDET says "this test is flaky", "passes locally fails in CI", "intermittent timeout", "why does this test flake", or pastes a test that fails ~1 in N runs. Root-causes races/timing/hard-waits/shared state, recommends deterministic fixes, and suggests trace/retry settings — a diagnosis the engineer confirms.
- License 许可
- MIT
- 最近更新
- 2026-07-15
- Stars
- ★ 4
- Forks
- 8
01 前言 Front Matter
- name
- pw-flaky-debugger
- license
- MIT
- metadata
- { "pack": "playwright", "author": "TheTestingAcademy", "version": "1.0.0" }
- description
- Diagnoses a flaky Playwright test and proposes web-first fixes. Use when an SDET says "this test is flaky", "passes locally fails in CI", "intermittent timeout", "why does this test flake", or pastes a test that fails ~1 in N runs. Root-causes races/timing/hard-waits/shared state, recommends deterministic fixes, and suggests trace/retry settings — a diagnosis the engineer confirms.
03 SKILL.md 正文
PW Flaky Debugger
You produce a root-cause hypothesis and fix the engineer must reproduce and verify — flakiness is confirmed by running, not by reading. You hunt the race.
When to use
- A test passes intermittently or only fails in CI.
- A timeout appears on an action/assertion that "should" be ready.
- Someone says "de-flake this", "why is this test flaky".
Workflow
- Reproduce, don't guess. Recommend
--repeat-each=20(and--workers=1vs parallel) to surface the flake and isolate whether it's ordering or timing. - Scan for the usual root causes:
- Hard waits (
waitForTimeout) andnetworkidlemasking a real race. - Non-web-first assertions (
expect(await locator.count())) that don't retry. - Shared/mutated state across tests or workers (same user, same DB row).
- Auto-waiting bypassed by
ElementHandle, or racing an animation/toast. - Strict-mode multi-match, or asserting before navigation settles.
- Hard waits (
- Prescribe the deterministic fix — replace waits with web-first assertions, isolate state per test, await the right signal (response, URL, visibility).
- Tune the safety net — enable
trace: 'on-first-retry', set retries in CI, and keep the fix, not the retry, as the real remedy. - State confidence and what to run to confirm the flake is gone.
Output shape
Flake diagnosis
Symptom : timeout on getByRole('button', { name: 'Save' }).click() — ~2/20 runs
Root cause: click races a modal fade-in; button is attached but not stable
Fix : assert dialog visible first; drop the waitForTimeout
Confirm : npx playwright test spec.ts --repeat-each=20 → expect 20/20
// before — racy
await page.waitForTimeout(500);
await page.getByRole('button', { name: 'Save' }).click();
// after — web-first, deterministic
await expect(page.getByRole('dialog')).toBeVisible();
await page.getByRole('button', { name: 'Save' }).click();
Guardrails
- The diagnosis is a hypothesis the engineer must reproduce — never declare a flake fixed without a repeat-run; never assume a selector or timing.
- Retries and
trace: 'on-first-retry'are a safety net, not the fix — always address the root race. - Never "fix" flake by adding
waitForTimeoutornetworkidle— that hides it. - Don't fabricate the cause; if the trace/logs weren't shown, ask for them.
04 同仓库更多 Skills
se-wait-fixer
Scans Selenium Java code for Thread.sleep and for implicit+explicit wait mixing, then replaces them with WebDriverWait/ExpectedConditions or FluentWait to fix synchronization. Use when an SDET says "remove Thread.sleep from my tests", "fix the flaky waits", "my implicit and explicit waits conflict", or pastes code full of hard sleeps. Produces refactors the engineer must run and confirm.
se-test-generator
Generates a runnable Selenium 4 + TestNG test in Java from a plain-language scenario, using explicit waits and stable locators. Use when an SDET says "write a Selenium test for login", "generate a TestNG test for the checkout flow", "automate this scenario in Selenium", or pastes Gherkin/steps and wants Java WebDriver code. Produces a draft test the engineer must review and run.
se-report-integrator
Integrates reporting (Allure or ExtentReports) into a Selenium + TestNG suite with listeners, screenshot-on-failure, and step logging. Use when an SDET says "add Allure to my tests", "set up ExtentReports", "capture a screenshot on failure", "add a TestNG listener for reporting", or wants readable run reports. Produces listener and config code the engineer must run to generate a report.
se-page-object-builder
Builds a Page Object Model class in Java (PageFactory @FindBy or explicit locators) with action methods and a WebDriverWait for a given page. Use when an SDET says "create a page object for the login page", "build a POM class", "refactor these locators into a page object", or pastes a page's fields and wants a reusable POM. Produces a draft class the engineer must review and run.
se-locator-strategist
Recommends and repairs Selenium locator strategy — replaces brittle absolute XPath with By.id, By.cssSelector, or Selenium 4 relative locators, and explains the trade-offs. Use when an SDET says "this XPath keeps breaking", "make this locator more stable", "why is my locator flaky", "convert this XPath to CSS", or pastes selectors to harden. Produces proposals the engineer must verify in the DOM.
se-grid-configurator
Configures Selenium Grid 4 (hub-and-node or standalone, including Docker) and wires RemoteWebDriver for parallel and distributed runs. Use when an SDET says "set up Selenium Grid", "run my tests on a remote grid", "dockerize Selenium Grid 4", "point my tests at RemoteWebDriver", or wants parallel execution across nodes. Produces config and code the engineer must run and validate in their environment.