AgentSkillsCN

e2e

基于评估驱动的开发框架,配备 pass@k 指标、能力/回归评估,以及评分器模式,助力功能的系统化验证。

SKILL.md
--- frontmatter
name: e2e
description: Generate and run end-to-end tests with Playwright. Creates test journeys, runs tests, captures screenshots/videos/traces, and uploads artifacts.
user-invocable: true
disable-model-invocation: true
context: fork

E2E Command

This command invokes the e2e-runner agent to generate, maintain, and execute end-to-end tests using Playwright.

What This Command Does

  1. Generate Test Journeys - Create Playwright tests for user flows
  2. Run E2E Tests - Execute tests across browsers
  3. Capture Artifacts - Screenshots, videos, traces on failures
  4. Upload Results - HTML reports and JUnit XML
  5. Identify Flaky Tests - Quarantine unstable tests

When to Use

Use /e2e when:

  • Testing critical user journeys (login, checkout, profile updates)
  • 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:

  1. Analyze user flow and identify test scenarios
  2. Generate Playwright test using Page Object Model pattern
  3. Run tests across multiple browsers (Chrome, Firefox, Safari)
  4. Capture failures with screenshots, videos, and traces
  5. Generate report with results and artifacts
  6. 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

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)

Quick Commands

bash
# Run all E2E tests
npx playwright test

# Run specific test file
npx playwright test tests/e2e/products/search.spec.ts

# Run in headed mode (see browser)
npx playwright test --headed

# Debug test
npx playwright test --debug

# Generate test code
npx playwright codegen http://localhost:3000

# View report
npx playwright show-report