From qa-skills
Generate end-to-end browser and API tests using Playwright ecosystem (Playwright Test, Playwright CLI, Playwright MCP).
How this skill is triggered — by the user, by Claude, or both
Slash command
/qa-skills:e2e-test-generatorThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Generate reliable end-to-end test suites using the Playwright ecosystem exclusively. Covers browser testing, API testing, visual regression, and component testing with proper selectors, wait strategies, and page object patterns.
Generate reliable end-to-end test suites using the Playwright ecosystem exclusively. Covers browser testing, API testing, visual regression, and component testing with proper selectors, wait strategies, and page object patterns.
Use this skill when the user asks for tasks like:
Use this skill for:
request context)Do not use this skill for:
api-test-generator)test-smell-detector)references/selector-strategy.mdreferences/wait-patterns.mdreferences/page-object-guide.mdreferences/playwright-cli-guide.mdexamples/Detect frontend framework:
# Check package.json for framework
grep -E "react|vue|angular|svelte|next|nuxt|gatsby|remix|astro" package.json 2>/dev/null | head -10
Detect existing Playwright setup:
find . -maxdepth 3 -name "playwright.config.*" | head -5
Check Playwright installation:
npx playwright --version 2>/dev/null
Identify target pages/flows:
# Find route definitions
grep -rl "Route\|path:\|to=" --include="*.tsx" --include="*.jsx" --include="*.vue" --include="*.ts" --include="*.js" src/ app/ pages/ 2>/dev/null | head -20
If no routes are discoverable, ask the user for:
Always use Playwright. Determine which Playwright capabilities to leverage:
| Capability | When to use |
|---|---|
Playwright Test (@playwright/test) | Default for all E2E tests |
Playwright CLI codegen (npx playwright codegen) | Quick test scaffolding from user interaction |
Playwright API testing (request context) | API calls within E2E flows (setup/teardown) |
Playwright Component Testing (@playwright/experimental-ct-*) | Testing React/Vue/Svelte components in isolation |
| Playwright MCP | AI-assisted test generation and browser automation |
| Playwright Trace Viewer | Debugging failed tests with timeline, snapshots, network |
| Need | Read this file |
|---|---|
| Choosing selectors (data-testid vs CSS vs text) | references/selector-strategy.md |
| Handling async loads, navigation, animations | references/wait-patterns.md |
| Page object model structure | references/page-object-guide.md |
For each user flow, generate:
Required patterns:
Test structure rules:
data-testid attributes as primary selectors (suggest adding them if missing)sleep() or fixed timeoutsbeforeEach for fresh stateshould <expected behavior> when <condition>Generated file structure (Playwright):
tests/
├── e2e/
│ ├── pages/
│ │ ├── login.page.ts
│ │ ├── dashboard.page.ts
│ │ └── base.page.ts
│ ├── login.spec.ts
│ ├── dashboard.spec.ts
│ └── fixtures/
│ └── auth.fixture.ts
├── playwright.config.ts
└── .env.test
Playwright config essentials:
// playwright.config.ts
import { defineConfig, devices } from '@playwright/test'
export default defineConfig({
testDir: './tests/e2e',
fullyParallel: true,
forbidOnly: !!process.env.CI,
retries: process.env.CI ? 2 : 0,
workers: process.env.CI ? 1 : undefined,
reporter: [['html'], ['list']],
use: {
baseURL: process.env.BASE_URL || 'http://localhost:3000',
trace: 'on-first-retry',
screenshot: 'only-on-failure',
video: 'on-first-retry',
},
projects: [
{ name: 'chromium', use: { ...devices['Desktop Chrome'] } },
{ name: 'firefox', use: { ...devices['Desktop Firefox'] } },
{ name: 'webkit', use: { ...devices['Desktop Safari'] } },
{ name: 'mobile-chrome', use: { ...devices['Pixel 5'] } },
{ name: 'mobile-safari', use: { ...devices['iPhone 13'] } },
],
webServer: {
command: 'npm run dev',
url: 'http://localhost:3000',
reuseExistingServer: !process.env.CI,
},
})
Auth state persistence (storageState):
// tests/e2e/auth.setup.ts
import { test as setup, expect } from '@playwright/test'
setup('authenticate', async ({ page }) => {
await page.goto('/login')
await page.getByTestId('login-email').fill(process.env.TEST_USER!)
await page.getByTestId('login-password').fill(process.env.TEST_PASSWORD!)
await page.getByTestId('login-submit').click()
await page.waitForURL('/dashboard')
await page.context().storageState({ path: '.auth/user.json' })
})
Playwright CLI quick-start commands:
# Initialize Playwright in project
npm init playwright@latest
# Generate tests interactively
npx playwright codegen http://localhost:3000
# Run all tests
npx playwright test
# Run with UI mode (interactive debugging)
npx playwright test --ui
# Run specific test file
npx playwright test tests/e2e/login.spec.ts
# Show HTML report
npx playwright show-report
# View trace file
npx playwright show-trace trace.zip
## E2E Test Generation Report
- **Framework**: Playwright Test
- **Playwright version**: <version>
- **Target app**: <URL or local path>
- **Pages/flows covered**: <count>
- **Test files generated**: <count>
- **Total test cases**: <count>
### Generated Files
| File | Flow | Test count |
|---|---|---|
### Selector Strategy
- Primary: data-testid → `page.getByTestId()`
- Fallback: role-based → `page.getByRole()`
- Avoided: CSS path, XPath indices
### Browser Coverage
- Chromium, Firefox, WebKit (desktop)
- Mobile Chrome (Pixel 5), Mobile Safari (iPhone 13)
### How to Run
\`\`\`bash
npm install
npx playwright install
npx playwright test
\`\`\`
### Useful Commands
\`\`\`bash
npx playwright test --ui # Interactive UI mode
npx playwright codegen <url> # Record new tests
npx playwright show-report # View test report
npx playwright test --trace on # Capture traces for debugging
\`\`\`
### Missing data-testid Attributes
- <list elements that need data-testid added>
Action:
npx playwright codegen <url> to interactively discover flowsAction:
npm init playwright@latestnpx playwright installAction:
getByRole, getByText, getByLabel as primary selectorsdata-testid additionsreferences/selector-strategy.mdreferences/wait-patterns.mdreferences/page-object-guide.mdreferences/playwright-cli-guide.mdexamples/npx claudepluginhub umitozdemirf/qa-skills --plugin qa-skillsGuides writing E2E tests with Playwright, configuring test infrastructure, debugging flaky browser tests, creating page objects, setting up fixtures, reporters, CI integration, API mocking, and visual regression testing.
Writes and debugs E2E tests with Playwright using Page Object Model, API mocking, and visual regression. Configures test infrastructure and CI integration.
Writes, runs, debugs, and maintains Playwright (@playwright/test) TypeScript tests for E2E UI behavior, API validation, responsive design, and visual regression in web apps.