/stackwise:playwright-expertfrom stackwise
Writes and fixes TypeScript E2E tests with Playwright: web-first assertions, role locators, storageState auth, network mocking (page.route/HAR), trace viewer flake diagnosis, visual regression (toHaveScreenshot), and CI sharding.
Ships in stackwise. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
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.
waitForTimeout, manual polling) to role locators and web-first assertionsstorageState so the suite logs in once per project, not once per testpage.route, route.fetch, or HAR replay to isolate the frontendtoHaveScreenshot and masking for dynamic contentplaywright.config.ts (projects, baseURL, webServer, storageState, reporters) and 2-3 existing specs to learn conventions: fixture files (test.extend in a fixtures.ts), POM classes, data-testid naming, auth setup project. Identify which project/spec the new coverage belongs in. Confirm the dev server the tests target actually starts (webServer block or a running instance).getByRole, getByLabel, getByTestId as escape hatch), web-first await expect(locator) assertions, zero waitForTimeout, zero networkidle. Isolate external/slow dependencies with page.route or HAR. Reuse the auth storageState; never script the login form inside the test. Load the matching reference (table below) before writing unfamiliar patterns.npx tsc --noEmit and the project's lint command (npx eslint .); fix all reported issues and re-run until clean before proceeding.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, then npx playwright show-trace (or --ui locally).npx playwright test <spec> --repeat-each=5 --workers=4; any failure is a race you introduced - fix the root cause (see references/flake-and-ci.md) and re-run until all repeats pass. Never "fix" this step with retries or timeouts.npx playwright test, or --only-changed on 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.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 |
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");
waitForTimeout anywhere. 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 use await expect.poll(() => fn()).toBe(x) or await expect(async () => {...}).toPass()..MuiButton-root > span, div:nth-child(3)). They break on every refactor and assert nothing about the user experience. Use getByRole/getByLabel; add data-testid to the app only when no accessible handle exists.setup project writing storageState once per role; per-test UI login is only for tests about the login flow.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/networkidle waits. waitForNavigation is deprecated and networkidle is unreliable on apps with polling/websockets. Assert on the destination instead: await expect(page).toHaveURL(/\/dashboard/) plus a visible landmark.toBeVisible() negation done once via expect(await locator.isVisible()).toBe(false) - passes even while the element is still rendering. Use await expect(locator).toBeHidden() or toHaveCount(0).expect. Web-first assertions return promises; a missing await makes the test pass vacuously. Enable @typescript-eslint/no-floating-promises (or eslint-plugin-playwright) so the linter catches it in step 4.fullyParallel on. Give each worker its own account (worker-scoped fixture keyed on test.info().parallelIndex) or make tests idempotent.What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
Other plugins' skills for the same job
16 skills in this plugin
/docker-expertUse when working with Dockerfile, docker-compose.yml, .dockerignore, or multi-stage builds. Build, debug, secure, and optimize Docker 27+ images and Docker Compose services./engineering-rulesUse when writing, modifying, or reviewing code in any language or framework. Applies to every code task in this repo and every code sample inside a skill: new features, bug fixes, refactors, generated snippets, tests, scripts, docs with code. Enforces the seven repo-wide rules: reusable code, maintainable structure, top-notch readability, no AI slop, dead code removal, why-only comments, no em dashes. Invoke for implementing changes, self-reviewing a diff, cleaning up generated code, writing reference examples, or reviewing a PR./fastapi-expertnpx claudepluginhub aarvion-ai/stackwise-skills --plugin stackwise