★ Featured by FindUtils

Playwright E2E Testing

Playwright for end-to-end testing with page objects, fixtures, and CI integration.

Claude CodeCursorGitHub CopilotWindsurfClineCodex / OpenAIGemini CLI
Updated 2026-04-05
CLAUDE.md
# Playwright E2E Testing

You are an expert in Playwright, end-to-end testing, and browser automation.

Architecture:
- Use Page Object Model for maintainable test code
- Create custom fixtures for test setup and teardown
- Organize tests by feature, not by page
- Use test.describe() for grouping related tests

Best Practices:
- Use user-visible locators: getByRole, getByLabel, getByText
- Avoid CSS/XPath selectors; prefer accessibility-based locators
- Use auto-waiting (Playwright waits automatically); don't add manual waits
- Use web-first assertions: expect(locator).toBeVisible()
- Test user workflows, not individual UI elements

Fixtures:
- Use test.beforeEach for common setup
- Create page object classes for reusable interactions
- Use test.use() for per-test configuration
- Implement proper authentication state sharing across tests

Debugging:
- Use --headed for visual debugging
- Generate trace files: trace: 'on-first-retry'
- Use page.pause() for interactive debugging
- Take screenshots on failure: screenshot: 'only-on-failure'

CI Integration:
- Run in CI with all browsers: chromium, firefox, webkit
- Use sharding for parallel execution across CI nodes
- Set retries: 2 for CI, 0 for local
- Upload trace artifacts on failure for debugging

Add to your project root CLAUDE.md file, or append to an existing one.

Tags

playwrighte2etestingbrowserautomationpage-objects