JPeetz/agent-skills / skills/qa-testing/playwright-e2e-testing
playwright-e2e-testing
VerifiedUse this skill when writing, debugging, or maintaining Playwright end-to-end tests in TypeScript, JavaScript, or Python. Covers test structure and architecture (Page Object Model, fixtures, custom matchers), locator strategy (role-based, test-ID, accessible selectors), auto-waiting and retry, API/network mocking, visual regression, component testing (React, Vue, Svelte), accessibility audits (axe-core), device emulation, authentication and session management (multi-profile, OAuth, 2FA), performance testing (Web Vitals, Lighthouse), CI/CD configuration (GitHub Actions, GitLab CI, sharding), flaky test detection and auto-healing, test data/fixtures, i18n testing, Electron and browser extension testing, security testing (XSS, CSRF, CSP), and WebSocket testing. Designed for agentic platforms — Claude Code, Codex, Cursor, Gemini CLI, OpenClaw, GitHub Copilot, Windsurf, OpenCode, and all SKILL.md-compatible agents.
| File | Kind | Size |
|---|---|---|
| CHANGELOG.md | markdown | 2.2 KB |
| LICENSE | other | 1.0 KB |
| SKILL.md | skill md | 23.4 KB |
| evals/evals.json | config | 5.3 KB |
| references/ci-cd-patterns.md | markdown | 2.5 KB |
| references/locator-strategies.md | markdown | 3.0 KB |
| references/testing-types-matrix.md | markdown | 3.2 KB |
| scripts/flake-detector.shexecutable | script | 2.0 KB |
| scripts/generate-auth-profile.ts | script | 3.4 KB |
| scripts/validate-playwright-setup.shexecutable | script | 2.2 KB |
references/locator-strategies.md
View on GitHub# Locator Strategies Reference
## Priority Hierarchy
Always use the most specific, accessible, and resilient locator first.
### Tier 1: Semantic Locators (Always Preferred)
| Locator | Usage | Resilience |
|---------|-------|------------|
| `getByRole('button', { name: 'Submit' })` | Any interactive element | ★★★★★ |
| `getByLabel('Email')` | Form inputs with `<label>` | ★★★★★ |
| `getByText('Welcome back')` | Static text content | ★★★★☆ |
| `getByPlaceholder('Search...')` | Inputs with placeholder | ★★★☆☆ |
| `getByAltText('Logo')` | Images with alt text | ★★★★☆ |
| `getByTitle('Close')` | Elements with title attr | ★★★☆☆ |
### Tier 2: Data Attributes (Fallback)
| Locator | Usage | Resilience |
|---------|-------|------------|
| `getByTestId('checkout-button')` | When no semantic element exists | ★★★☆☆ |
### Tier 3: CSS/XPath (Avoid)
| Locator | Usage | Resilience |
|---------|-------|------------|
| `locator('.btn-primary')` | CSS class targeting | ★☆☆☆☆ |
| `locator('#submit')` | ID targeting | ★★☆☆☆ |
| `locator('button >> nth=0')` | Positional | ☆☆☆☆☆ |
## Anti-Patterns — Examples to Avoid
```typescript
// ❌ POSITIONAL — breaks when DOM changes
await page.locator('button').first().click();
await page.locator('div > div:nth-child(3) > button').click();
// ❌ CSS CLASS — coupling to styling
await page.locator('.bg-blue-500.hover\\:bg-blue-600').click();
// ❌ XPath — slow, fragile, unreadable
await page.locator('//div[@class="modal"]//button[contains(text(),"OK")]').click();
// ❌ Visible text that changes with i18n
await page.getByText('Submit').click(); // Will break in other languages
```
## Best Practice Patterns
```typescript
// ✅ Role + accessible name
await page.getByRole('button', { name: /submit/i }).click();
// ✅ Label association
await page.getByLabel('Email address').fill('user@test.com');
// ✅ Role filter with current state
await page.getByRole('button', { name: 'Save', disabled: false }).click();
// ✅ Chained selectors for repeated structures
const row = page.getByRole('row', { name: /Order #1234/ });
await row.getByRole('button', { name: 'View details' }).click();
// ✅ Filter by text for dynamic lists
await page.getByRole('listitem').filter({ hasText: 'In stock' }).click();
// ✅ Test ID as escape hatch
await page.getByTestId('pricing-total').toHaveText('$99.00');
```
## Framework-Specific Guidance
### React
- Use `data-testid` attributes sparingly; prefer accessible roles
- Components should expose ARIA roles and labels properly
- Use `getByRole` with accessible names from your component API
### Angular
- Leverage built-in accessibility (Angular components often have good roles)
- Use `data-cy` or `data-test` attributes consistently
- Angular Material components have predictable role patterns
### Vue
- Use `data-test` as fallback; prefer semantic HTML
- Vue Test Utils integration works with component mounting
- Template refs don't map to DOM; don't rely on them
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| rea-analysis-optimizationmorluto/reaOptimize REA providers and shared analysis workflows for agent context, latency, CPU, and memory while preserving correctness and Evidence. Use for analysis bottlenecks and cache or query design; CI/test-suite optimization belongs to rea-ci-tests-audit. | Stars: 471k | Updated | Claude CodeCodex | Verified | Install |
| rea-ci-tests-auditmorluto/reaAudit REA CI and test suites for correctness, fixture drift, false passes, and measured performance; use for suite or workflow investigations and efficiency changes, rather than ordinary feature testing or a single test failure. | Stars: 471k | Updated | Claude CodeCodex | Verified | Install |
| rea-tool-designmorluto/reaAudit, investigate, design, or change REA investigation tools, CLI/MCP contracts, provider capabilities, and Evidence semantics. | Stars: 471k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-auditDietrichGebert/ponytailQuality audit of the whole repo: bugs, security, real load, missing tests, speed, and what to delete. Most important first. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |