
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-codeInstalls 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:
page.getByRole('button', { name: 'Submit' })— accessibility rolespage.getByLabel('Email')— form control labelspage.getByPlaceholder('Search...')— input placeholderspage.getByText('Welcome')— visible text (non-interactive)page.getByAltText('Logo')— image alt textpage.getByTitle('Settings')— title attributespage.getByTestId('submit-btn')— explicit test contracts- 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- Axe Ios Simulator239
- Electrobun Best Practices209
- Tilt196
- Orbstack Best Practices180
- Canton Network Repos157
- Ios Device Screenshot155
- Atlas Best Practices154
- Git Best Practices149
- Git Rebase Sync146
- Testing Best Practices135
- E2e126
- Extract Transcripts122
- React Best Practices3K
- Typescript Best Practices2.9K
- Python Best Practices1.8K
- Web Fetch929
- Zig Best Practices388
- Nix Best Practices359
- Tamagui Best Practices290
- Openai Image Gen288
- Go Best Practices272