AGENT SKILL

playwright

Robust E2E browser testing with Playwright. Use when writing browser-driven tests — leverage auto-waiting (no `waitForTimeout`), prefer user-visible locators (`getByRole`, `getByText`, `getByLabel`) over CSS/XPath, reuse `storageState` for auth, and enable trace-on-first-retry for CI debugging.

License 许可
MIT
最近更新
2026-05-27
Stars
★ 0
Forks
0

01 前言 Front Matter

name
playwright
vendor
playwright
description
Robust E2E browser testing with Playwright. Use when writing browser-driven tests — leverage auto-waiting (no `waitForTimeout`), prefer user-visible locators (`getByRole`, `getByText`, `getByLabel`) over CSS/XPath, reuse `storageState` for auth, and enable trace-on-first-retry for CI debugging.

03 SKILL.md 正文

Skill: Playwright

Policy Capsule

  • Rely on Playwright's auto-waiting; never use waitForTimeout or hardcoded sleeps to paper over flakes.
  • Prefer user-visible locators (getByRole, getByText, getByLabel) over CSS selectors or XPath.
  • Reuse storageState to seed authenticated scenarios; do not repeat login flows in every test.
  • Use toHaveScreenshot() for critical visual surfaces; treat snapshot diffs as intentional reviews, not auto-refreshes.
  • Write tests independent of one another so they run in parallel; clean up shared state in fixtures, not afterwards.
  • Enable trace: 'on-first-retry' (or 'retain-on-failure') so CI failures are debuggable in the Trace Viewer.
  • Use a unique data set per test run, or tear down state explicitly, to prevent cross-test contamination.

Standard operating procedures for robust, end-to-end (E2E) browser testing.

1. Core Principles

  • End-to-End focus: Test the application as a user would, through the browser.
  • Auto-waiting: Leverage Playwright's built-in auto-waiting instead of hardcoded waitForTimeout calls.
  • Resilience: Write tests that survive minor UI changes (e.g., color tweaks) by using robust selectors.

2. Technical Standards

  • Locators: Use user-visible locators (e.g., getByRole, getByText, getByLabel) over brittle CSS selectors or XPath.
  • State Management: Use storageState to reuse authentication between tests, avoiding repetitive login flows.
  • Visual Testing: Use toHaveScreenshot() for critical UI layouts to detect visual regressions.

3. Best Practices

  • Parallelism: Ensure tests are independent so they can run concurrently to reduce CI time.
  • Tracing: Enable trace recording on failure to quickly debug CI issues with the Playwright Trace Viewer.
  • Test Data: Use a unique data set per test run or clean up state to prevent cross-contamination.

04 同仓库更多 Skills

chrisbarrantes
chrisbarrantes/mandrel

no-capsule-skill

Fixture without a Policy Capsule section.

★ 0
chrisbarrantes
chrisbarrantes/mandrel

backend-security-patterns

Combined backend protocols for authentication (Clerk JWT verification) and PII-safe observability. Use when handling auth on the server, verifying Clerk webhooks via `svix`, scoping metadata via `publicMetadata`/ `privateMetadata`, or sanitizing logs to keep emails, tokens, and request bodies out of telemetry.

★ 0
chrisbarrantes
chrisbarrantes/mandrel

vitest

Writes fast, isolated unit and integration tests with Vitest. Use when each test must run on file-save without shared state — `vi.mock()` for external deps, `vi.spyOn()` for call monitoring, AAA structure, and edge-case coverage for null/undefined/boundary inputs.

★ 0
chrisbarrantes
chrisbarrantes/mandrel

playwright-bdd

Wires Gherkin `.feature` files to Playwright via the `playwright-bdd` library. Use when running BDD scenarios on a Playwright runtime — pairs with the `gherkin-authoring` skill (scenario prose) and the `playwright` skill (browser conventions). Drives execution by tag expression with trace-first debugging and Playwright-native sharding.

★ 0
chrisbarrantes
chrisbarrantes/mandrel

lighthouse-baseline

Codifies the capture-and-check baseline pattern for long-running quality signals (Lighthouse scores, bundle size, p95 latency, runtime memory). Use when wiring a new metric that needs a baseline file, paired :capture / :check npm scripts, a tolerance-bounded gate, and a weekly refresh cadence — the goal is a hard CI signal that ratchets only with intent.

★ 0
chrisbarrantes
chrisbarrantes/mandrel

gherkin-authoring

Authors `.feature` files that stay business-readable, translate cleanly from PRD acceptance criteria, and reuse a shared step-definition library. Use when writing or editing scenarios — the SSOT enforcement rules live in `.agents/rules/gherkin-standards.md`; this skill shows authors how to apply them.

★ 0