agentleFS
ldaumeldaume/agentic-engineering-harness/skills/testing/playwright-best-practices/SKILL.md

playwright-best-practices

Skill3 starsChanged 3 months agoMITView on GitHub

Writes, reviews, and debugs Playwright tests for web apps with stable locators, fixtures, auth setup, API mocking, trace debugging, responsive checks, accessibility assertions, and CI reliability. Use when creating Playwright tests, fixing flaky e2e tests, debugging traces, testing UI flows, or configuring browser tests.

20 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use nodejs-backend-patterns, next-cache-components and 9 more.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • xfstudioSkill

    nodejs-backend-patterns

    Build production-ready Node.js backend services with Express/Fastify, implementing middleware patterns, error handling, authentication, database integration, and API design best practices. Use when creating Node.js servers, REST APIs, GraphQL backends, or microservices architectures.

    Also in 5 projects that use this

  • VercelSkill

    next-cache-components

    Next.js 16 Cache Components - PPR, use cache directive, cacheLife, cacheTag, updateTag

    Also in 4 projects that use this

  • VercelSkill

    next-upgrade

    Upgrade Next.js to the latest version following official migration guides and codemods

    Also in 3 projects that use this

  • midudevSkill

    tailwind-css-patterns

    Provides comprehensive Tailwind CSS utility-first styling patterns including responsive design, layout utilities, flexbox, grid, spacing, typography, colors, and modern CSS best practices. Use when styling React/Vue/Svelte components, building responsive layouts, implementing design systems, or optimizing CSS workflow.

    Also in 3 projects that use this

  • KadajettSkill

    nestjs-best-practices

    NestJS best practices and architecture patterns for building production-ready applications. This skill should be used when writing, reviewing, or refactoring NestJS code to ensure proper patterns for modules, dependency injection, security, and performance.

    Also in 3 projects that use this

  • xenitV1Skill

    nodejs-best-practices

    Node.js development principles and decision-making. Framework selection, async patterns, security, and architecture. Teaches thinking, not copying.

    Also in 3 projects that use this

  • +1 more from vercel-labs

The file

Show its rules and text

We split this skill into the rules it gives an agent

13 rules. 0 are common, 11 are distinctive, and 2 are very specific to this project.

  • 0

    Common

    Most of the 20 edited versions we read keep these.

  • 11

    Distinctive

    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:

    Use this for browser-level tests that should behave like a reliable user.

    line 8
  2. Distinctive:

    Read existing Playwright config, fixtures, helpers, test ids, auth setup, route mocks, and CI commands.

    line 14
  3. Distinctive:

    Follow the repo's locator strategy.

    line 16
  4. Distinctive:

    Keep assertions tied to user-visible behavior and accessibility semantics.

    line 18
  5. Distinctive:

    Do not add sleeps to hide race conditions.

    line 19
  6. Distinctive:

    Prefer role, label, text, and stable test ids over CSS selectors.

    line 23
  7. Distinctive:

    Keep tests isolated and repeatable.

    line 25
  8. Distinctive:

    Use fixtures for auth and shared setup.

    line 30
  9. Distinctive:

    Keep mobile/responsive tests explicit when layout or touch behavior matters.

    line 33
  10. Very specific:

    Use getByRole when semantics are stable and meaningful.

    line 46
  11. Very specific:

    Use getByLabel for form controls.

    line 47
  12. Distinctive:

    Use project test ids for complex widgets or localized copy.

    line 48
  13. Distinctive:

    Avoid nth-child selectors unless testing ordered content explicitly.

    line 49

“Common” is measured: kept by at least 6 in 10 of the 20 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.

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

Playwright Best Practices

Use this for browser-level tests that should behave like a reliable user.

Project Fit Check

Before writing tests:

  1. Read existing Playwright config, fixtures, helpers, test ids, auth setup, route mocks, and CI commands.
  2. Follow the repo's locator strategy.
  3. Reuse existing page objects/helpers only when they reduce duplication.
  4. Keep assertions tied to user-visible behavior and accessibility semantics.
  5. Do not add sleeps to hide race conditions.

Test Rules

  • Prefer role, label, text, and stable test ids over CSS selectors.
  • Assert the outcome, not every implementation step.
  • Keep tests isolated and repeatable.
  • Leaving a page through a client-side navigation is not finished when the click returns. Wait for the destination before starting the next navigation: a goto into a navigation still in flight aborts it, and the failure is intermittent, which in a release gate means the gate decides by coin toss.
  • Use fixtures for auth and shared setup.
  • Mock external services at the boundary when real services make tests slow or flaky.
  • Keep mobile/responsive tests explicit when layout or touch behavior matters.

Debugging Flow

  1. Reproduce with the smallest test command.
  2. Inspect trace, screenshot, console, and network output.
  3. Identify whether the failure is product bug, selector drift, async race, data setup, browser difference, or environment issue.
  4. Fix the cause, not the timeout.
  5. Re-run the failed test and any nearby coverage.

Locator Rules

  • Use getByRole when semantics are stable and meaningful.
  • Use getByLabel for form controls.
  • Use project test ids for complex widgets or localized copy.
  • Avoid nth-child selectors unless testing ordered content explicitly.

Red Flags

  • waitForTimeout
  • goto immediately after a click that navigates
  • broad CSS selectors
  • tests depend on run order
  • production third-party service required for normal CI
  • assertion passes before async work completes
  • UI changed but accessibility name no longer matches intent

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.