一键导入
playwright-debugging
Diagnostic Playwright workflows for flaky or failing tests, including trace analysis, UI mode, and state isolation.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Diagnostic Playwright workflows for flaky or failing tests, including trace analysis, UI mode, and state isolation.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
Playwright workflows for authenticated browser state reuse through storageState and setup projects.
Conducts rigorous authoring and review of Playwright E2E tests. Enforces accessibility-first locators, web-first assertions, strict isolation, and DAMP architecture. Use when generating, refactoring, or reviewing any Playwright test code.
Playwright workflows for deterministic third-party responses using page.route().
基于 SOC 职业分类
| name | playwright-debugging |
| description | Diagnostic Playwright workflows for flaky or failing tests, including trace analysis, UI mode, and state isolation. |
Use this skill when a Playwright test fails intermittently, behaves differently in CI, or passes locally but not in a repeatable way. The goal is to identify the specific cause of the failure before changing the test.
Use this skill as the first stop for failures. It is not a rewrite guide and it is not a replacement for playwright-core when the test still needs normal authoring discipline.
This skill focuses on four common failure classes: timing and readiness issues, state bleed between tests, hydration or rendering gaps in SPA frameworks, and flakiness that only appears under CI's specific constraints.
Do not use this skill to redesign a test from scratch unless the current test is beyond repair or the user explicitly asks for a rewrite.
Start with evidence. Use the failing error, the trace viewer, or the exact step that failed before choosing a fix.
If the failing step is ambiguous, inspect the trace before editing. Do not generalize from one red run.
The UI is present, but the app is not ready for interaction yet. In this case, wait for the state the user would observe, not for an arbitrary timer.
Use web-first assertions, actionability checks, or a specific network response instead of waitForTimeout().
import { test, expect } from '@playwright/test';
test('submits the form after the data load completes', async ({ page }) => {
const responsePromise = page.waitForResponse('**/api/v1/data-load');
await page.goto('/dashboard');
await responsePromise;
await expect(page.getByRole('button', { name: 'Submit' })).toBeEnabled();
await page.getByRole('button', { name: 'Submit' }).click();
});
The test depends on data that another test created or failed to clean up. Make the test self-contained by setting up its own data, storage state, or API state.
Prefer test-local setup over cross-test ordering. If the state comes from login, use a saved storage state. If it comes from application data, create it within the test or through a setup step.
The DOM appears before event handlers or framework state are attached. Wait for the interactive signal, not just the presence of elements.
This often shows up in React, Next.js, or other SPA frameworks when text is visible before a button is actually usable.
A test that is stable locally but flaky only in CI is not the same problem as timing, state bleed, or hydration on their own — it usually means a fix that works on a single local run doesn't hold up under CI's actual constraints: parallel workers competing for resources, shared services under load, and machines slower than a dev laptop.
Do not assume a local pass means the underlying fix is complete. Before closing out a CI-only flake, check for:
test.info().workerIndex) instead of tightening a timeout..env and CI secrets. Confirm the test isn't passing
locally only because of state that doesn't exist in CI.Reproduce the CI failure mode locally under real constraints instead of guessing:
npx playwright test --workers=4 --repeat-each=10
If the failure only reproduces under load or parallelism, the fix belongs in resource isolation or wait strategy, not in a longer timeout.
--repeat-each to prove a fix is stable.--trace on when the issue needs a replayable record.If the symptom points to app state rather than locator choice, confirm whether the test needs a setup project, a route mock, or a proper reset between runs before making the test more complex.
After the fix, confirm the failure no longer reproduces under repetition.
Typical checks:
npx playwright test tests/example.spec.ts --repeat-each=5
npx playwright test tests/example.spec.ts --ui
Use the trace viewer to confirm the original failure mode is gone and that the fix matches the observed state change.
If the failure was intermittent, keep the repeat count high enough to make a false green unlikely. One passing run is not enough evidence for a flake repair. If the flake was CI-only, verify with --workers set to match your CI configuration, not just --repeat-each alone.