0xbigboss avatar

Playwright Best Practices

A solid reference for writing resilient Playwright tests that won't break every time the UI changes. It pushes you toward getByRole and getByLabel instead of CSS selectors, which actually matters when refactoring. The CLI reporter guidance is smart if you're running tests through Claude Code, since default reporters dump thousands of tokens into context. Most valuable for the locator priority list and the auth state reuse pattern, both of which save a ton of maintenance time. The anti-patterns section catches the usual mistakes like waitForTimeout and shared test state. Worth having active if you're touching any .spec.ts files.

skills.sh installs
266
GitHub stars
48
last updated
Jun 3, 2026

Install

$ npx -y skills add 0xbigboss/claude-code --skill playwright-best-practices --agent claude-code

Installs into .claude/skills of the current project.

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

Sponsors

Details

Repository
github.com/0xbigboss/claude-code
Category
Testing & QA
First seen
Jun 3, 2026

More from 0xbigboss/claude-code

All 22
1sickn33 avatartdd-workflows-tdd-greensickn33/antigravity-awesome-skillstdd workflows tdd green263skills.sh installs
2patricio0312rev avatarcontract-testing-builderpatricio0312rev/skillsImplements API contract testing to ensure provider-consumer compatibility using Pact or similar tools. Prevents breaking changes with contract specifications an262skills.sh installs
3cinience avataralicloud-platform-aliyun-cli-testcinience/alicloud-skillsMinimal smoke test for generic Alibaba Cloud aliyun CLI skill. Validate CLI install, auth profile, and one read-only API call.240skills.sh installs
4vabole avatarswift-testingvabole/apple-skillsswift testing230skills.sh installs
5arpitg1304 avatarrobotics-testingarpitg1304/robotics-agent-skills>215skills.sh installs
6manojbajaj95 avatarab-test-setupmanojbajaj95/claude-gtm-pluginWhen the user wants to plan, design, or implement an A/B test or experiment. Also use when the user mentions "A/B test," "split test," "experiment," "test this 215skills.sh installs