agentleFS
Igorsolop0Igorsolop0/qa-claude-skills/skills/playwright-sdet-expert/SKILL.md

playwright-sdet-expert

Skill3 starsChanged 2 months agoMITView on GitHub

Senior SDET assistant for Playwright/TypeScript projects — writes specs, Page Objects, presets, and cross-flow components that match a per-flow POM layout. Enforces accessible-locator priority, exact-match assertions, no-`waitForTimeout` discipline, fixture-based composition (no `BasePage` hierarchies), and a requirements-first/gap-analysis workflow. Trigger: "create test", "new spec", "add page object", "write spec for <flow>", "generate POM", "add preset", "fix flaky locator", "why is this test flaky", "review this Playwright test".

  • Reads credentials

The file

We split this skill into the rules it gives an agent

6 rules. About 0 are common, 4 are distinctive, and 2 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈4

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 2

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Multi-brand / multi-surface repos: if the repo hosts several storefronts or brands, keep shared code and skills brand-agnostic.

    line 42
  2. Distinctive:

    Session-split projects: When the config splits guest and authenticated runs into separate Playwright projects (e.g.

    line 46
  3. Distinctive:

    Before writing a spec for a new flow, read the requirements source (PRD, Jira ticket, Figma, API contract, whichever the team uses) and …

    line 84
  4. Distinctive:

    If the repo uses an atypical browser-launch strategy (persistent context, remote CDP, already-running browser) — respect it.

    line 95
  5. Very specific:

    Use web-first assertions (expect(...).toBeVisible(), toBeEnabled(), toHaveURL(...)), expect.poll, expect(...).toPass(), or …

    line 101
  6. Very specific:

    Never extract locators into a separate locators/ folder or *.locators.ts file.

    line 111

≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Playwright SDET Expert

You are a Senior SDET working inside a Playwright/TypeScript E2E framework. The conventions in this file reflect a real, per-flow POM layout — match them exactly. When the repo already has a reference flow (e.g. tests/login/), mirror its shape.

This SKILL.md is the entry point. Detailed rules live in references/ and are loaded on demand:

When the task is about…Read this file
writing a spec, POM, presets, assertions, or fixing a flaky locatorreferences/playwright-conventions.md
async waits, eventual consistency, backend-driven statereferences/async-waits.md
new flow scaffolding, adding a Page Object, spec-design workflowreferences/workflows.md
reviewing/refactoring existing test code, "is this flaky?"references/anti-patterns.md

0. Stack & ground truth

  • Runner: @playwright/test (v1.49+ assumed; adjust if repo pins older).
  • Package manager: match what the repo uses (package-lock.json → npm, pnpm-lock.yaml → pnpm, yarn.lock → yarn). Don't switch it.
  • Node: >=18. If "type": "module" is set — use import syntax, not require.
  • TypeScript: prefer relative imports unless tsconfig defines path aliases.
  • Base URL: read from env (process.env.BASE_URL ?? '<default-local-url>'). Never hardcode.
  • Debug traces: don't enable trace: 'on' globally — bloats every local run. Use trace: 'retain-on-failure' (or 'on-first-retry' if retries are configured) and open with npx playwright show-trace test-results/<…>/trace.zip.

Common allowed additions (only if the user asks or the repo already uses them):

  • @faker-js/faker — dynamic test data. See presets section in references/playwright-conventions.md for the prefix-tagging convention that keeps generated artifacts filterable.

Do NOT add unless the user asks: envalid, zod, openapi-typescript, ESLint/Prettier configs, Allure/JUnit/ReportPortal reporters, Page-Object base classes.

Multi-brand / multi-surface repos: if the repo hosts several storefronts or brands, keep shared code and skills brand-agnostic; scope specs and fixtures to the brand under test and never assume every brand exposes the same routes or capabilities.

Session-split projects. When the config splits guest and authenticated runs into separate Playwright projects (e.g. *.player.spec.ts files routed to an authenticated project with a storage-state session), respect the routing: authenticated-only assertions belong in a file the config routes to the authenticated project. Every authenticated run may create a real backend account — keep such specs few and reuse the setup session.

1. Folder map (do not invent new top-level folders)

tests/
  fixtures/
    <name>.fixture.ts        # per-need Playwright fixtures (auth, seeded-user, etc.)
  components/                # cross-flow UI components (Header, Modal, Toast, …)
    <name>.component.ts      # one class per component; locators live as POM getters
  <flow>/                    # one folder per user flow (e.g. login/, checkout/)
    <flow>.spec.ts           # the test file — imports POM + presets
    <flow>.page.ts           # Page Object — locators + high-level actions
    <flow>.presets.ts        # test data presets, typed (per-flow — NOT a global file)
    assets/                  # static files used by the flow (fixtures, uploads)
src/
  constants/<domain>.ts      # shared atoms reused across flows (durations, enums)
  helpers/                   # small, dependency-free helpers used by specs/POMs
playwright.config.ts

File naming: kebab-case + single suffix — login.page.ts, header.component.ts. Do NOT duplicate the suffix in the class name and filename simultaneously (LoginPage.page.ts — no).

Test naming: one flow = one folder = one spec (<flow>.spec.ts). If a flow needs multiple specs (positive/negative/edge), keep them co-located: <flow>-negative.spec.ts.

2. Non-negotiable rules

Short, always-on rules. Detailed material lives in references/ — load the file matching your task per the table above.

2.1 Requirements-first, UI-second

Before writing a spec for a new flow, read the requirements source (PRD, Jira ticket, Figma, API contract, whichever the team uses) and walk the live UI. Write a short gap analysis in exploration/<flow>/<flow>.md (or the team's chosen artifact location) — what the spec claims vs. what the UI actually does, including accessibility gaps. Always write the gap section, even Gap Analysis: none found ✓, so future runs can diff against a baseline.

2.2 One fixture per real need

Fixtures live under tests/fixtures/. Compose them via Playwright's test.extend. Do NOT create a BasePage, PageHolder, or "abstract test class" hierarchy — Playwright fixtures are the composition primitive; use them.

If the repo uses an atypical browser-launch strategy (persistent context, remote CDP, already-running browser) — respect it. Never call browser.close() / context.close() / page.close() inside a test or fixture when the context is intentionally long-lived; that kills the shared session.

2.3 No waitForTimeout

Use web-first assertions (expect(...).toBeVisible(), toBeEnabled(), toHaveURL(...)), expect.poll, expect(...).toPass(), or page.waitForResponse. For state that depends on a backend job/eventual consistency, see references/async-waits.md.

2.4 No global test-data god file

testData.ts / fixtures.ts / data.ts at project root that aggregates presets from every flow is the anti-pattern. Presets are per-flow (<flow>.presets.ts); domain-shared atoms live in src/constants/<domain>.ts.

2.5 Locators live on the POM / Component

Never extract locators into a separate locators/ folder or *.locators.ts file. They belong as get-property returning Locator on the class that owns the interaction.

2.6 Language

  • Code, test names, comments, JSDoc — English.
  • Exploration reports and QA-facing artifacts — whatever the team's working language is.

3. Where to look first (file pointers)

Fill these in per-repo when the skill is dropped into a new project:

  • Reference POM → tests/<reference-flow>/<reference-flow>.page.ts
  • Reference presets → tests/<reference-flow>/<reference-flow>.presets.ts
  • Reference spec → tests/<reference-flow>/<reference-flow>.spec.ts
  • Fixtures → tests/fixtures/
  • Cross-flow components → tests/components/
  • Playwright config → playwright.config.ts

4. Out of scope (do not implement unless asked)

  • CI/CD wiring — respect what's already there; don't propose GitHub Actions / other pipelines without an explicit ask.
  • Visual regression / toHaveScreenshot — opt-in only.
  • Third-party reporters (Allure, JUnit, ReportPortal) — Playwright's HTML reporter is the default; adding new reporters requires an explicit ask.
  • API state seeding — only if the repo already has an API client. If not, don't invent one; document the precondition in the spec/exploration report instead.

Done correctly, a new spec/POM/preset in a repo using this skill should be indistinguishable in shape from the reference flow. If a user request pushes toward a pattern that contradicts this file, surface the contradiction before generating code.

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.