| name | e2e |
| description | Generate and run end-to-end tests with Playwright. Use when user says "run e2e", "end-to-end test", "playwright test", or "test user flow". Creates test journeys, captures screenshots/videos/traces, and detects flaky tests. |
E2E Command
This command invokes the e2e-runner agent to generate, maintain, and execute end-to-end tests using Playwright.
What This Command Does
- Generate Test Journeys - Create Playwright tests for user flows
- Run E2E Tests - Execute tests across browsers
- Capture Artifacts - Screenshots, videos, traces on failures
- Upload Results - HTML reports and JUnit XML
- Identify Flaky Tests - Quarantine unstable tests
When to Use
Use /e2e when:
- Testing critical user journeys (login, trading, payments)
- Verifying multi-step flows work end-to-end
- Testing UI interactions and navigation
- Validating integration between frontend and backend
- Preparing for production deployment
How It Works
The e2e-runner agent will:
- Analyze user flow and identify test scenarios
- Generate Playwright test using Page Object Model pattern
- Run tests across multiple browsers (Chrome, Firefox, Safari)
- Capture failures with screenshots, videos, and traces
- Generate report with results and artifacts
- Identify flaky tests and recommend fixes
Test Artifacts
When tests run, the following artifacts are captured:
On All Tests:
- HTML Report with timeline and results
- JUnit XML for CI integration
On Failure Only:
- Screenshot of the failing state
- Video recording of the test
- Trace file for debugging (step-by-step replay)
- Network logs
- Console logs
Flaky Test Detection
If a test fails intermittently:
FLAKY TEST DETECTED: tests/e2e/markets/trade.spec.ts
Test passed 7/10 runs (70% pass rate)
Recommended fixes:
1. Add explicit wait: await page.waitForSelector('[data-testid="confirm-btn"]')
2. Increase timeout: { timeout: 10000 }
3. Check for race conditions in component
4. Verify element is not hidden by animation
Quarantine recommendation: Mark as test.fixme() until fixed
Quick Commands
npx playwright test
npx playwright test tests/e2e/markets/search.spec.ts
npx playwright test --headed
npx playwright test --debug
npx playwright codegen http://localhost:3000
npx playwright show-report
Best Practices
DO:
- Use Page Object Model for maintainability
- Use data-testid attributes for selectors
- Wait for API responses, not arbitrary timeouts
- Test critical user journeys end-to-end
- Run tests before merging to main
- Review artifacts when tests fail
DON'T:
- Use brittle selectors (CSS classes can change)
- Test implementation details
- Run tests against production
- Ignore flaky tests
- Skip artifact review on failures
- Test every edge case with E2E (use unit tests)
Integration with Other Commands
- Use
/plan to identify critical journeys to test
- Use
/tdd for unit tests (faster, more granular)
- Use
/e2e for integration and user journey tests
- Use
/code-review to verify test quality
Related Agents
This command invokes the e2e-runner agent located at:
~/.claude/agents/e2e-runner.md