Skip to content
alleneubank avatar

Playwright Best Practices

Playwright test guidance that enforces role-based locators, web-first assertions, and isolated, auth-reused tests.

CCM score
46 of 100
skills.sh installs
380
GitHub stars
49
last updated
Jun 3, 2026
View on GitHub

Own this skill? Claim it

What it does

  • Covers locator priority from accessibility roles down to CSS and XPath, with CSS and XPath treated as last resort
  • Includes core rules for web-first assertions, per-test data isolation, storageState auth reuse, and fixtures over beforeEach
  • Enforces a minimal line or dot reporter for CLI and CI runs to keep test output from overflowing agent context
  • Designed for writing or modifying Playwright .spec.ts and .test.ts files that import @playwright/test

Install

$ npx -y skills add alleneubank/claude-code --skill playwright-best-practices -y

Installs into .agents/skills for every agent it finds here, and .claude/skills for Claude Code.

Files

Playwright Best Practices

CLI Context: Prevent Context Overflow

When running Playwright tests from Claude Code or any CLI agent, always use minimal reporters to prevent verbose output from consuming the context window.

Use --reporter=line or --reporter=dot for CLI test runs. Configure playwright.config.ts to default to minimal reporters when CI or CLAUDE env vars are set — see playwright-patterns.md for the config snippet.

Locator Priority (Most to Least Resilient)

Always prefer user-facing attributes:

  1. page.getByRole('button', { name: 'Submit' }) — accessibility roles
  2. page.getByLabel('Email') — form control labels
  3. page.getByPlaceholder('Search...') — input placeholders
  4. page.getByText('Welcome') — visible text (non-interactive)
  5. page.getByAltText('Logo') — image alt text
  6. page.getByTitle('Settings') — title attributes
  7. page.getByTestId('submit-btn') — explicit test contracts
  8. CSS/XPath — last resort, avoid

Core Rules

Details

Repository
github.com/alleneubank/claude-code
Categories
Testing & QA, Browser Automation & Scraping
First seen
Jun 3, 2026

Questions

What does the playwright-best-practices skill do?

playwright-best-practices guides an agent when it writes or modifies Playwright tests in .spec.ts or .test.ts files that import @playwright/test. It steers locator choice toward role, label and test id selectors, prefers web-first assertions, and reuses saved auth state through a setup project and storageState.

How do I install playwright-best-practices?

Run npx -y skills add alleneubank/claude-code --skill playwright-best-practices -y in your project. Once installed, playwright-best-practices loads when the agent edits Playwright test files, and its checklist covers isolation, fixtures and minimal reporters for CLI runs.

Where does playwright-best-practices fit among Testing & QA skills?

playwright-best-practices is listed in the Testing & QA category with tdd, webapp-testing and break-ui. Its focus is narrower than general test-driven development: it targets Playwright specifically, covering selector priority, anti-patterns such as waitForTimeout, and reporter settings that keep agent output short.

Does playwright-best-practices need any tools or accounts?

playwright-best-practices needs an agent that can read and edit Playwright test files, and a project where Playwright is set up. Its own SKILL.md references a playwright-patterns.md file for configuration and Page Object examples.

More from alleneubank/claude-code

All 8

Similar to Playwright Best Practices

More Testing & QA