Skip to content

borghei/Claude-Skills / engineering/playwright-pro

playwright-pro

Verified

End-to-end testing with Playwright: test generation, page objects, locator strategy, flaky- test diagnosis, visual regression, and CI integration. Use when writing E2E tests, fixing flaky tests, or migrating from Cypress/Selenium.

skills/init.md

View on GitHub
# Sub-Skill: Project Initialization

**Parent:** playwright-pro
**Trigger:** "set up Playwright", "initialize e2e tests", "add Playwright to project"

## Purpose

Bootstrap a Playwright testing environment from scratch in an existing project. Handles installation, configuration, directory structure, first test, and CI integration.

## Workflow

### Step 1: Install Dependencies

```bash
# Detect package manager
pnpm add -D @playwright/test
pnpm exec playwright install --with-deps chromium firefox
```

### Step 2: Generate Configuration

Create `playwright.config.ts` following the golden rules:
- `baseURL` from environment variable with localhost fallback
- `retries: 2` in CI, `0` locally
- `trace: 'on-first-retry'`
- `screenshot: 'only-on-failure'`
- Projects: chromium + firefox + mobile-chrome
- Auth setup project with `storageState`

### Step 3: Create Directory Structure

```
tests/
├── e2e/
│   ├── auth.setup.ts        # Shared authentication
│   ├── smoke.spec.ts         # First smoke test
│   └── __fixtures__/         # Test data
├── pages/                    # Page Objects
│   └── base.page.ts          # Base page class
└── helpers/                  # Test utilities
    └── test-data.ts          # Data factory helpers
```

### Step 4: Write Smoke Test

Generate a minimal smoke test that validates the app loads, the page title is correct, and no console errors appear. This confirms the setup works end-to-end.

### Step 5: Add to CI

Add a GitHub Actions job or extend existing pipeline with the Playwright step. Include artifact upload for reports on failure.

### Step 6: Verify

```bash
npx playwright test tests/e2e/smoke.spec.ts --reporter=list
```

## Inputs

| Input | Required | Description |
|-------|----------|-------------|
| Package manager | No | Auto-detected (pnpm > npm > yarn) |
| Base URL | No | Defaults to http://localhost:3000 |
| Browsers | No | Defaults to chromium + firefox + mobile |

## Outputs

- `playwright.config.ts` configured per golden rules
- Directory structure with first smoke test
- CI workflow step (if requested)
- Confirmation the smoke test passes
finishing-a-development-branchobra/superpowersUse when implementation is complete, all tests pass, and you need to decide how to integrate the workStars: 322kUpdated Claude CodeCodexVerifiedInstall
systematic-debuggingobra/superpowersUse when encountering any bug, test failure, or unexpected behavior, before proposing fixesStars: 322kUpdated Claude CodeCodexVerifiedInstall
test-driven-developmentobra/superpowersUse when implementing any feature or bugfix, before writing implementation codeStars: 322kUpdated Claude CodeCodexVerifiedInstall
skill-creatoranthropics/skillsCreate new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an existing skill, run evals to test a skill, benchmark skill performance with variance analysis, or optimize a skill's description for better triggering accuracy.Stars: 198kUpdated Claude CodeCodexVerifiedInstall