e2e
Playwright E2E testing patterns. Use when working on files in tests/e2e/.
When & Why to Use This Skill
This Claude skill provides a comprehensive framework for Playwright End-to-End (E2E) testing, designed to streamline the creation of resilient and efficient test suites. It enforces industry best practices such as journey-style testing, accessible selector prioritization, and the elimination of flaky tests, ensuring high-quality software delivery through automated web testing patterns.
Use Cases
- Scenario 1: Developing robust E2E test suites for critical user journeys to ensure core application flows remain functional.
- Scenario 2: Optimizing test execution speed by utilizing test steps and avoiding redundant setup flows in existing test files.
- Scenario 3: Standardizing selector strategies across a development team by prioritizing getByRole and getByTestId for better maintainability.
- Scenario 4: Debugging and resolving flaky tests in CI/CD environments using specialized Playwright CLI commands for worker and repetition management.
- Scenario 5: Implementing reusable helper functions for complex, multi-step processes like user identity creation and navigation.
| name | e2e |
|---|---|
| description | Playwright E2E testing patterns. Use when working on files in tests/e2e/. |
E2E Test Guidelines
Philosophy
- Journey-style tests covering critical flows end-to-end
- Strongly prefer adding
test.step()to existing tests over creating new tests - keeps suite fast and avoids duplicating slow setup flows - Fix flaky tests immediately, regardless of when introduced
Commands
pnpm playwright test --reporter=line --max-failures=1 2>&1
pnpm playwright test --workers=4 --repeat-each=5 --reporter=line 2>&1 # flaky detection
NEVER use --debug or --ui - opens GUI, blocks forever. This is a common mistake.
Selectors (priority order)
getByRole()getByTestId()getByLabel()getByText(/regex/i)
Critical Rules
- Assert behaviour, not text - text changes with copy edits/i18n
- Independent tests - use
beforeEach, don't depend on prior test state - No arbitrary waits - use
toBeEnabled(), notwaitForTimeout()
Helpers
Import from tests/e2e/helpers/:
createNewIdentity(page)- full new user flowgoToTransactions(page),goToTags(page), etc.
Create helpers for multi-step reused flows. Don't wrap single Playwright calls.
Pattern
test.describe("Feature", () => {
test.beforeEach(async ({ page }) => {
await createNewIdentity(page);
await goToFeature(page);
});
test("should do thing", async ({ page }) => {
// Arrange → Act → Assert
});
});