Specialist e2e runner

From VenTheZone/pi-dots · View interactive version

Specialist e2e runner is an AI agent skill from the GitHub repository VenTheZone/pi-dots. End-to-end test specialist for creating, maintaining, and executing Playwright tests with artifact and flaky-test management. Use when writing E2E tests for critical user journeys, debugging failures from HTML/JUnit reports, hunting flaky tests, or wiring E2E into CI.

How to use this skill

Skill file

Specialist: E2E Test Runner

End-to-end testing specialist ensuring critical user journeys work in production. Writes, maintains, and executes Playwright tests with proper artifact capture and flaky-test handling.

Workflow

  1. Plan journeys — identify critical user flows and prioritize by risk
  2. Create tests — write Page Object Model tests with robust locators and key-step assertions
  3. Run locally — execute targeted and full suites; capture screenshots/videos/traces on failure
  4. Manage flakiness — repro with repeats and retries, then quarantine unstable tests
  5. Integrate & report — wire into CI, generate HTML report + JUnit XML, verify metrics

Playwright Commands

# Run all / a specific file
npx playwright test
npx playwright test tests/markets.spec.ts

# Debug and explore
npx playwright test --headed
npx playwright test --debug
npx playwright codegen http://localhost:3000

# Traces, snapshots, reports
npx playwright test --trace on
npx playwright show-report
npx playwright test --update-snapshots

# Per-browser
npx playwright test --project=chromium

# Stability / retries
npx playwright test tests/markets/search.spec.ts --repeat-each=10
npx playwright test tests/markets/search.spec.ts --retries=3

Page Object Model Pattern

Keep locators and interactions in one place so UI changes stay manageable:

// pages/MarketsPage.ts
import { Page, Locator } from '@playwright/test'

export class MarketsPage {
  readonly page: Page
  readonly searchInput: Locator
  readonly marketCards: Locator

  constructor(page: Page) {
    this.page = page
    this.searchInput = page.locator('[data-testid="search-input"]')
    this.marketCards = page.locator('[data-testid="market-card"]')
  }

  async goto() {
    await this.page.goto('/markets')
    await this.page.waitForLoadState('networkidle')
  }

  async searchMarkets(query: string) {
    await this.searchInput.fill(query)
    await this.page.waitForResponse(r => r.url().includes('/api/markets/search'))
  }
}

Robust test using the page object:

test('should search markets by keyword', async ({ page }) => {
  await expect(page).toHaveTitle(/Markets/)

  await marketsPage.searchMarkets('trump')

  const marketCount = await marketsPage.getMarketCount()
  expect(marketCount).toBeGreaterThan(0)
  await expect(marketsPage.marketCards.first()).toContainText(/trump/i)
  await page.screenshot({ path: 'artifacts/search-results.png' })
})

Flaky Test Management

Prefer waiting for the actual condition over arbitrary waits:

// FLAKY: assume element ready / arbitrary timeout
await page.click('[data-testid="button"]')
await page.waitForTimeout(5000)

// STABLE: auto-wait + wait for condition
await page.locator('[data-testid="button"]').click()
await page.waitForResponse(r => r.url().includes('/api/markets'))

Quarantine a flaky test rather than deleting it:

test.fixme(true, 'Test is flaky - Issue #123')
test.skip(process.env.CI, 'Test is flaky in CI - Issue #123')

Test Report Format

# E2E Test Report

**Date:** YYYY-MM-DD HH:MM
**Duration:** Xm Ys
**Status:** PASSING / FAILING

## Summary
- **Total:** X | **Passed:** Y (Z%) | **Failed:** A | **Flaky:** B | **Skipped:** C

## Failed Tests
### 1. search with special characters
**File:** `tests/e2e/markets/search.spec.ts:45`
**Error:** Expected element to be visible, but was not found
**Screenshot:** artifacts/search-special-chars-failed.png
**Recommended Fix:** Escape special characters in search query

Success Metrics

Remember: E2E tests are the last line of defense before production. Invest in making them stable, fast, and comprehensive.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.