agentleFS
isabelle-barpisabelle-barp/agent-brain/skills/stack-playwright/SKILL.md

stack-playwright

Skill0 starsChanged 5 months agoApache-2.0View on GitHub

Playwright end-to-end testing craft for projects whose docs/TECH_STACK.md lists playwright. Loaded by e2e-tester, frontend-developer, mobile-developer (web views), release-gatekeeper.

The file

We split this skill into the rules it gives an agent

3 rules. About 0 are common, 3 are distinctive, and 0 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈3

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 0

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Every suite runs against at least two seeded tenants and asserts isolation: actions performed in tenant A's session are never visible from …

    line 35
  2. Distinctive:

    Test isolation: every spec creates or selects its own data via the seed fixtures.

    line 40
  3. Distinctive:

    RED first (BDD): run new specs against the missing implementation and observe the failure for the right reason — testid not rendered / …

    line 47

≈ “Common” is an estimate: at least 1 in 5 of the 408,460 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

Stack: Playwright

Playwright is the e2e runner for the web surfaces of .claude/rules/TESTING_E2E.md — this file carries the runner-specific craft. The binding e2e policy (spec-only context, thin tip, red-first, dockerized suite) lives in that rule file; the FE↔E2E data-testid contract lives in .claude/skills/stack-nextjs-react/SKILL.md. Where the host's docs/DEV_SETUP.md declares different run targets, the host docs win.

When this applies

Detection markers (any of):

  • docs/TECH_STACK.md ## Detected stacks lists playwright
  • Dependencies: @playwright/test (devDependency of the e2e project)
  • Files: playwright.config.{ts,js,mjs}, an e2e/ directory (or apps/*-e2e) containing .spec.ts files using page fixtures

Implementation patterns

Selector discipline

  • page.getByTestId(...) against the SPEC_<FEATURE>.md §7.3 data-testid registry ONLY. Never visible-text, role, label, or CSS-structure selectors (R-TESTE-02 in .claude/rules/TESTING_E2E.md) — visible text dies on i18n/copy edits; CSS structure dies on restyle.
  • A getByTestId value not in §7.3 is an invented ID — a §7 gap to route back through /create-spec, never a workaround.

AC mapping

  • One e2e spec per AC crossing the UI/HTTP boundary, named so it maps back to the spec: test('AC-<FEATURE>-NN: <behavior>', ...) with GIVEN/WHEN/THEN comments aligned to the spec wording (R-TESTE-03). One test, one AC — a mega-test covering five ACs cannot tell you which one broke.

Fixtures over beforeEach state

  • Preconditions come from custom test.extend fixtures (auth fixture, seeded-tenant fixture), not from mutable beforeEach blocks. Fixture-seeded data is the substrate every spec stands on — each spec creates or selects its own rows through the fixture; the project's dev seed script is NOT a fixture (R-TEST-07 in .claude/rules/TESTING_COMMON.md).
  • storageState reuse for auth: authenticate once in a setup project, persist storageState, and have suites consume it — never log in through the UI in every spec.
  • Page Object ONLY for surfaces used by 3+ specs; otherwise inline locators. A PO class wrapping a single spec's locators is over-abstraction — a smell, not hygiene.

Network policy

  • The e2e suite hits the REAL dockerized stack (R-TESTE-06). page.route() stubbing is allowed ONLY for third-party externals (payment sandboxes, analytics beacons). Stubbing your own API in an e2e is a BLOCKER — the test then verifies the stubs, not the system.

Multi-tenant

  • Every suite runs against at least two seeded tenants and asserts isolation: actions performed in tenant A's session are never visible from tenant B's session. A tenant-scoped feature without this assertion has untested isolation.

Anti-flakiness discipline

  • Web-first assertions — await expect(locator).toHaveText(...) / .toBeVisible() auto-retry until timeout. page.waitForTimeout() is a BLOCKER: it converts a race into a sleep and the race always wins eventually.
  • Explicit waitFor only on network/navigation edges (page.waitForURL, page.waitForResponse) — never as a sleep substitute for rendering.
  • Test isolation: every spec creates or selects its own data via the seed fixtures; no inter-spec order dependence — the suite must pass shuffled, repeated, and in parallel.
  • Retries are a flakiness ALARM, not a fix. Config may carry retries for CI signal, but a spec that passes only on retry is a defect to triage, never a green to ship.
  • Artifacts are the debugging contract: trace: 'on-first-retry', screenshot + video on failure. A flake without a trace is unreproducible by the next agent.

Testing on this stack

How the suite itself is validated:

  • RED first (BDD): run new specs against the missing implementation and observe the failure for the right reason — testid not rendered / route absent, not a typo in the test (R-TESTE-04). Commit RED with the failure mode in the commit body.
  • Full run inside the docker compose e2e profile (R-TESTE-06): the runner is itself a container; docker compose --profile e2e up on a clean checkout is the entire setup. Zero URLs in the Playwright config point outside the compose network.
  • Parallel workers with per-worker isolation: each worker gets its own DB schema or its own seeded tenant (worker-scoped fixture keyed on workerInfo.workerIndex) so workers never share state; enable fully-parallel mode only when that isolation holds.

Spec validation checks

Stack-specific checks the spec validators (spec-validate-ui / spec-validate-final, on SPEC_<FEATURE>.md §7–§9) and code-reviewer (on e2e diffs) delegate here:

CheckSeverity
AC crossing the UI boundary (§8 UI-flagged) with no e2e test named AC-<FEATURE>-NNBLOCKER
getByTestId value in a spec file absent from the SPEC_<FEATURE>.md §7.3 registryBLOCKER
Own-API stubbing (page.route on a first-party endpoint) in an e2eBLOCKER
waitForTimeout anywhere in the e2e suiteBLOCKER
No multi-tenant isolation assertion where the feature is tenant-scopedWARNING
Page Object class for a surface used by a single specWARNING

Live validation commands

R-VAL-04 obligations for e2e changes — exact invocations live in docs/DEV_SETUP.md; the rows below are the obligations:

CheckTypical shape
Full suite in the compose e2e profiledocker compose --profile e2e up --abort-on-container-exit --exit-code-from e2e per DEV_SETUP
Targeted run / triagenpx playwright test <file> against the compose stack; --last-failed to re-run only failures
Inspect failure artifactsnpx playwright show-report / npx playwright show-trace <trace.zip>
New specs: red-first evidencerun once, observe the failure mode, capture it in the commit body (R-VAL-04)

"Pass" means the observation matched the task's BDD intent — RED for new specs against unbuilt UI, GREEN otherwise. All rows must pass before commit per .claude/rules/LIVE_VALIDATION.md.

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.