playwright-expert
Skill5 starsChanged 3 months agoMITView on GitHub
Use when writing or fixing E2E tests in a Playwright project - playwright.config.ts, *.spec.ts files under tests/ or e2e/, @playwright/test imports - or right after implementing a frontend/backend change that needs an end-to-end proof. Writes and extends TypeScript E2E suites as the QA gate for feature and bug-fix work, stabilizes flaky tests, sets up storageState auth, mocks the network with page.route/HAR, and wires parallel/sharded CI. Invoke for adding E2E coverage for a change, converting waitForTimeout/CSS-selector tests to web-first assertions and role locators, diagnosing flake with the trace viewer, adding toHaveScreenshot visual checks, and configuring sharded CI runs.
- Reads credentials
5 other projects use a version of this.
Adopted by
Most recently taken up by
- Leo-Atienza/atlas-claudetheir own version, first seen Jul 24, 2026
- iamdemetris/lude-kittheir own version, first seen Jul 17, 2026
- codeApe-7/ai-agent-workflowGrouptheir own version, first seen Jun 6, 2026
- usmanmubarak1/ClaudeSkilledAgentstheir own version, first seen Feb 6, 2026
- Jeffallan/claude-skillstheir own version, first seen Dec 26, 2025
Other versions5 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 5
- Jeffallan/claude-skills★ 12ksame name
- codeApe-7/ai-agent-workflowGroup★ 17same name
- Leo-Atienza/atlas-claude★ 4same name
- iamdemetris/lude-kit★ 0same name
- usmanmubarak1/ClaudeSkilledAgents★ 0same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository15 other files it gives its agents.
- docker-expertSkill
- engineering-rulesSkill
- fastapi-expertSkill
- fastify-expertSkill
- flutter-expertSkill
- go-expertSkill
- jetpack-compose-expertSkill
- mobile-qa-expertSkill
- nestjs-expertSkill
- react-expertSkill
- react-native-expertSkill
- remix-expertSkill
- swiftui-expertSkill
- terraform-expertSkill
- vue-expertSkill
The file
We split this skill into the rules it gives an agent
4 rules. 0 are common, 1 is distinctive, and 3 are very specific to this project.
0
Common
Most of the 5 edited versions we read keep these.
1
Distinctive
This author's own choices. Worth a look.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 19
Write or extend the E2E test that proves a just-implemented feature or bug fix works end to end
- Very specific: line 25
Add visual regression checks with toHaveScreenshot and masking for dynamic content
- Very specific: line 32
Verify types/lint: - run npx tsc --noEmit and the project's lint command (npx eslint .).
- Very specific: line 35
Gate the change: - run the full affected suite (npx playwright test, or --only-changed on large suites) across configured projects.
“Common” is measured: kept by at least 6 in 10 of the 5 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Playwright Expert
Turns Claude into a senior QA engineer who treats Playwright as the merge gate: every feature or bug fix ships with an E2E test that proves it, built on web-first assertions, user-facing locators, and fixtures - never sleeps, never brittle selectors.
When to Use This Skill
- Write or extend the E2E test that proves a just-implemented feature or bug fix works end to end
- Convert brittle tests (CSS/XPath selectors,
waitForTimeout, manual polling) to role locators and web-first assertions - Set up authentication with
storageStateso the suite logs in once per project, not once per test - Mock or record network traffic with
page.route,route.fetch, or HAR replay to isolate the frontend - Diagnose and fix flaky tests using traces - treat retries as a symptom, not a fix
- Configure parallelism, sharding, and blob-report merging for CI
- Add visual regression checks with
toHaveScreenshotand masking for dynamic content
Core Workflow
- Analyze - Read
playwright.config.ts(projects,baseURL,webServer,storageState, reporters) and 2-3 existing specs to learn conventions: fixture files (test.extendin afixtures.ts), POM classes,data-testidnaming, auth setup project. Identify which project/spec the new coverage belongs in. Confirm the dev server the tests target actually starts (webServerblock or a running instance). - Specify the behavior - For a feature: the user journey that exercises it (navigate → act → observe). For a bug fix: a test that fails on the old code and passes on the fix - reproduce first, then assert the corrected behavior. One behavior per test; put shared journey steps in fixtures or POMs, not copy-paste.
- Implement - Role/label locators first (
getByRole,getByLabel,getByTestIdas escape hatch), web-firstawait expect(locator)assertions, zerowaitForTimeout, zeronetworkidle. Isolate external/slow dependencies withpage.routeor HAR. Reuse the authstorageState; never script the login form inside the test. Load the matching reference (table below) before writing unfamiliar patterns. - Verify types/lint - run
npx tsc --noEmitand the project's lint command (npx eslint .); fix all reported issues and re-run until clean before proceeding. - Run the new tests -
npx playwright test <spec> --project=chromium; fix all failures and re-run until clean. Debug failures with the trace, not by adding waits:npx playwright test <spec> --trace on, thennpx playwright show-trace(or--uilocally). - Prove stability -
npx playwright test <spec> --repeat-each=5 --workers=4; any failure is a race you introduced - fix the root cause (seereferences/flake-and-ci.md) and re-run until all repeats pass. Never "fix" this step with retries or timeouts. - Gate the change - run the full affected suite (
npx playwright test, or--only-changedon large suites) across configured projects; fix all reported issues and re-run until clean. Confirm the HTML report shows the new tests passing without retry annotations.
Reference Guide
Load detailed guidance only when the task needs it:
| Topic | Reference | Load When |
Locator strategy, chaining/filtering, web-first assertions, expect.poll/toPass, aria snapshots | references/locators-assertions.md | Writing any new test, replacing CSS/XPath selectors, fixing "element not found"/strict-mode violations, asserting async state |
Custom fixtures, storageState auth setup project, multi-role login, POM vs fixture composition | references/fixtures-auth.md | Suite needs login, tests repeat setup steps, adding a fixtures file, choosing between POM classes and fixtures |
page.route, route.fetch modification, HAR record/replay, WebSocket routing, request assertions | references/network-mocking.md | Isolating the UI from a backend, testing error/edge responses, third-party APIs in tests, deterministic data |
| Flake diagnosis with traces, root-cause table, retries policy, CI workers/sharding/blob reports | references/flake-and-ci.md | A test fails intermittently, configuring CI, slow pipeline, --shard/merge-reports, choosing retry counts |
toHaveScreenshot options, masking, snapshot updates, cross-platform snapshots in Docker, aria vs pixel checks | references/visual-regression.md | Adding/updating screenshot tests, snapshot diffs on CI only, masking dynamic regions, visual review of a UI change |
Key Patterns
Web-first assertion instead of wait-then-check (the #1 conversion):
// BAD - checks once, races the UI, needs a sleep to "work"
await page.waitForTimeout(2000);
expect(await page.locator(".toast").textContent()).toBe("Saved");
// GOOD - auto-retries until pass or timeout; no sleep anywhere
await expect(page.getByRole("status")).toHaveText("Saved");Role locators scoped by filtering, not CSS paths:
const row = page.getByRole("row").filter({ hasText: "invoice-2026-08" });
await row.getByRole("button", { name: "Approve" }).click();
await expect(row.getByRole("cell", { name: "Approved" })).toBeVisible();Login once per run via a setup project, reuse everywhere:
// auth.setup.ts - runs once; specs never see the login form
setup("authenticate", async ({ page }) => {
await page.goto("/login");
await page.getByLabel("Email").fill(process.env.E2E_USER!);
await page.getByLabel("Password").fill(process.env.E2E_PASS!);
await page.getByRole("button", { name: "Sign in" }).click();
await expect(page.getByRole("navigation")).toBeVisible();
await page.context().storageState({ path: "playwright/.auth/user.json" });
});
// playwright.config.ts: chromium project has
// { dependencies: ["setup"], use: { storageState: "playwright/.auth/user.json" } }Deterministic backend edge case via route interception:
await page.route("**/api/orders", (route) =>
route.fulfill({ status: 500, json: { error: "upstream timeout" } })
);
await page.goto("/orders");
await expect(page.getByRole("alert")).toContainText("try again");Common Mistakes
waitForTimeoutanywhere. It hides a race and sets a floor on suite time. Replace with a web-first assertion on the condition being waited for; for non-DOM conditions useawait expect.poll(() => fn()).toBe(x)orawait expect(async () => {...}).toPass().- CSS/XPath selectors copied from DevTools (
.MuiButton-root > span,div:nth-child(3)). They break on every refactor and assert nothing about the user experience. UsegetByRole/getByLabel; adddata-testidto the app only when no accessible handle exists. - Logging in inside every test. Multiplies runtime and flake surface. Use a
setupproject writingstorageStateonce per role; per-test UI login is only for tests about the login flow. - Adding
retries(or bumping timeouts) to "fix" flake. Retries are detection - a test that passes on retry is still broken. Pull the trace from the failed attempt, find the race, fix the test or the app. waitForNavigation/networkidlewaits.waitForNavigationis deprecated andnetworkidleis unreliable on apps with polling/websockets. Assert on the destination instead:await expect(page).toHaveURL(/\/dashboard/)plus a visible landmark.- Asserting non-existence with
toBeVisible()negation done once viaexpect(await locator.isVisible()).toBe(false)- passes even while the element is still rendering. Useawait expect(locator).toBeHidden()ortoHaveCount(0). - Unawaited
expect. Web-first assertions return promises; a missingawaitmakes the test pass vacuously. Enable@typescript-eslint/no-floating-promises(oreslint-plugin-playwright) so the linter catches it in step 4. - Sharing signed-in state across tests that mutate the same account data with
fullyParallelon. Give each worker its own account (worker-scoped fixture keyed ontest.info().parallelIndex) or make tests idempotent.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

