New: Earn 20% as an AgentAlley affiliate. Share your link and earn on every sale you refer. Join now New: Earn 20% as an affiliate. Join now

Set up Playwright in a project

Initialize Playwright Project

by alirezarezvani · MIT license · ★ 26,349 on GitHub · updated Aug 30

Initialize Playwright Project cover

Set up Playwright in a project. Use when user says "set up playwright", add e2e tests", "configure playwright", "testing setup", "init playwright", or "add test infrastructure".

---
name: "pw-init"
description: >-
  Set up Playwright in a project. Use when user says "set up playwright",
  "add e2e tests", "configure playwright", "testing setup", "init playwright",
  or "add test infrastructure".
---

# Initialize Playwright Project

Set up a production-ready Playwright testing environment. Detect the framework, generate config, folder structure, example test, and CI workflow.

## Steps

### 1. Analyze the Project

Use the `Explore` subagent to scan the project:

Overview

Set up a production-ready Playwright testing environment. Detect the framework, generate config, folder structure, example test, and CI workflow.

What you get

  • Config file path and key settings
  • Test directory and example test
  • CI workflow (if applicable)
  • npm scripts added
  • How to runnpx playwright test or npm run test:e2e
Manual install (npx, ZIP)
Claude Codenpx skills add alirezarezvani/claude-skills --skill pw-init -g -a claude-code
Claude Code (manual)mkdir -p ~/.claude/skills && curl -sL https://codeload.github.com/alirezarezvani/claude-skills/tar.gz/19392f7a0826 \ | tar -xz -C ~/.claude/skills --strip-components=4 claude-skills-19392f7a0826/engineering-team/playwright-pro/skills/pw-init
Windows (PowerShell)New-Item -ItemType Directory -Force "$HOME\.claude\skills" | Out-Null; Invoke-WebRequest "https://m.agentalley.io/zip/f606ac06c3f256f1d60f/pw-init.zip" -OutFile "$env:TEMP\pw-init.zip"; Expand-Archive "$env:TEMP\pw-init.zip" -DestinationPath "$HOME\.claude\skills" -Force
Claude.ai / desktopDownload the ZIP and upload it under Settings → Capabilities → Skills.
Codex, Cursor, other agentsPoint them at SKILL.md. The other files are plain text.

Connects with Agent Alley MCP · agentalley.io/mcp

Files included

  • SKILL.md4.6 KB
Read the files here
alirezarezvani/19392f71 file
Shared references2SKILL.md reads these from elsewhere in the repo. Not in the ZIP.Get them on GitHub ↗
SKILL.md
Show the full text202 lines

Initialize Playwright Project

Set up a production-ready Playwright testing environment. Detect the framework, generate config, folder structure, example test, and CI workflow.

Steps

1. Analyze the Project

Use the Explore subagent to scan the project:

  • Check package.json for framework (React, Next.js, Vue, Angular, Svelte)
  • Check for tsconfig.json → use TypeScript; otherwise JavaScript
  • Check if Playwright is already installed (@playwright/test in dependencies)
  • Check for existing test directories (tests/, e2e/, __tests__/)
  • Check for existing CI config (.github/workflows/, .gitlab-ci.yml)
2. Install Playwright

If not already installed:

npm init playwright@latest -- --quiet

Or if the user prefers manual setup:

npm install -D @playwright/test
npx playwright install --with-deps chromium
3. Generate playwright.config.ts

Adapt to the detected framework:

Next.js:

import { defineConfig, devices } from '@playwright/test';

export default defineConfig({
  testDir: './e2e',
  fullyParallel: true,
  forbidOnly: !!process.env.CI,
  retries: process.env.CI ? 2 : 0,
  workers: process.env.CI ? 1 : undefined,
  reporter: [
    ['html', { open: 'never' }],
    ['list'],
  ],
  use: {
    baseURL: 'http://localhost:3000',
    trace: 'on-first-retry',
    screenshot: 'only-on-failure',
  },
  projects: [
    { name: "chromium", use: { ...devices['Desktop Chrome'] } },
    { name: "firefox", use: { ...devices['Desktop Firefox'] } },
    { name: "webkit", use: { ...devices['Desktop Safari'] } },
  ],
  webServer: {
    command: 'npm run dev',
    url: 'http://localhost:3000',
    reuseExistingServer: !process.env.CI,
  },
});

React (Vite):

  • Change baseURL to http://localhost:5173
  • Change webServer.command to npm run dev

Vue/Nuxt:

  • Change baseURL to http://localhost:3000
  • Change webServer.command to npm run dev

Angular:

  • Change baseURL to http://localhost:4200
  • Change webServer.command to npm run start

No framework detected:

  • Omit webServer block
  • Set baseURL from user input or leave as placeholder
4. Create Folder Structure
e2e/
├── fixtures/
│   └── index.ts          # Custom fixtures
├── pages/
│   └── .gitkeep          # Page object models
├── test-data/
│   └── .gitkeep          # Test data files
└── example.spec.ts       # First example test
5. Generate Example Test
import { test, expect } from '@playwright/test';

test.describe('Homepage', () => {
  test('should load successfully', async ({ page }) => {
    await page.goto('/');
    await expect(page).toHaveTitle(/.+/);
  });

  test('should have visible navigation', async ({ page }) => {
    await page.goto('/');
    await expect(page.getByRole('navigation')).toBeVisible();
  });
});
6. Generate CI Workflow

If .github/workflows/ exists, create playwright.yml:

name: "playwright-tests"

on:
  push:
    branches: [main, dev]
  pull_request:
    branches: [main, dev]

jobs:
  test:
    timeout-minutes: 60
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          node-version: lts/*
      - name: "install-dependencies"
        run: npm ci
      - name: "install-playwright-browsers"
        run: npx playwright install --with-deps
      - name: "run-playwright-tests"
        run: npx playwright test
      - uses: actions/upload-artifact@v4
        if: ${{ !cancelled() }}
        with:
          name: "playwright-report"
          path: playwright-report/
          retention-days: 30

If .gitlab-ci.yml exists, add a Playwright stage instead.

7. Update .gitignore

Append if not already present:

/test-results/
/playwright-report/
/blob-report/
/playwright/.cache/
8. Add npm Scripts

Add to package.json scripts:

{
  "test:e2e": "playwright test",
  "test:e2e:ui": "playwright test --ui",
  "test:e2e:debug": "playwright test --debug"
}
9. Verify Setup

Run the example test:

npx playwright test

Report the result. If it fails, diagnose and fix before completing.

Output

Confirm what was created:

  • Config file path and key settings
  • Test directory and example test
  • CI workflow (if applicable)
  • npm scripts added
  • How to run: npx playwright test or npm run test:e2e
1---
2name: "pw-init"
3description: >-
4 Set up Playwright in a project. Use when user says "set up playwright",
5 "add e2e tests", "configure playwright", "testing setup", "init playwright",
6 or "add test infrastructure".
7---
8 
9# Initialize Playwright Project
10 
11Set up a production-ready Playwright testing environment. Detect the framework, generate config, folder structure, example test, and CI workflow.
12 
13## Steps
14 
15### 1. Analyze the Project
16 
17Use the `Explore` subagent to scan the project:
18 
19- Check `package.json` for framework (React, Next.js, Vue, Angular, Svelte)
20- Check for `tsconfig.json` → use TypeScript; otherwise JavaScript
21- Check if Playwright is already installed (`@playwright/test` in dependencies)
22- Check for existing test directories (`tests/`, `e2e/`, `__tests__/`)
23- Check for existing CI config (`.github/workflows/`, `.gitlab-ci.yml`)
24 
25### 2. Install Playwright
26 
27If not already installed:
28 
29```bash
30npm init playwright@latest -- --quiet
31```
32 
33Or if the user prefers manual setup:
34 
35```bash
36npm install -D @playwright/test
37npx playwright install --with-deps chromium
38```
39 
40### 3. Generate `playwright.config.ts`
41 
42Adapt to the detected framework:
43 
44**Next.js:**
45```typescript
46import { defineConfig, devices } from '@playwright/test';
47 
48export default defineConfig({
49 testDir: './e2e',
50 fullyParallel: true,
51 forbidOnly: !!process.env.CI,
52 retries: process.env.CI ? 2 : 0,
53 workers: process.env.CI ? 1 : undefined,
54 reporter: [
55 ['html', { open: 'never' }],
56 ['list'],
57 ],
58 use: {
59 baseURL: 'http://localhost:3000',
60 trace: 'on-first-retry',
61 screenshot: 'only-on-failure',
62 },
63 projects: [
64 { name: "chromium", use: { ...devices['Desktop Chrome'] } },
65 { name: "firefox", use: { ...devices['Desktop Firefox'] } },
66 { name: "webkit", use: { ...devices['Desktop Safari'] } },
67 ],
68 webServer: {
69 command: 'npm run dev',
70 url: 'http://localhost:3000',
71 reuseExistingServer: !process.env.CI,
72 },
73});
74```
75 
76**React (Vite):**
77- Change `baseURL` to `http://localhost:5173`
78- Change `webServer.command` to `npm run dev`
79 
80**Vue/Nuxt:**
81- Change `baseURL` to `http://localhost:3000`
82- Change `webServer.command` to `npm run dev`
83 
84**Angular:**
85- Change `baseURL` to `http://localhost:4200`
86- Change `webServer.command` to `npm run start`
87 
88**No framework detected:**
89- Omit `webServer` block
90- Set `baseURL` from user input or leave as placeholder
91 
92### 4. Create Folder Structure
93 
94```
95e2e/
96├── fixtures/
97│ └── index.ts # Custom fixtures
98├── pages/
99│ └── .gitkeep # Page object models
100├── test-data/
101│ └── .gitkeep # Test data files
102└── example.spec.ts # First example test
103```
104 
105### 5. Generate Example Test
106 
107```typescript
108import { test, expect } from '@playwright/test';
109 
110test.describe('Homepage', () => {
111 test('should load successfully', async ({ page }) => {
112 await page.goto('/');
113 await expect(page).toHaveTitle(/.+/);
114 });
115 
116 test('should have visible navigation', async ({ page }) => {
117 await page.goto('/');
118 await expect(page.getByRole('navigation')).toBeVisible();
119 });
120});
121```
122 
123### 6. Generate CI Workflow
124 
125If `.github/workflows/` exists, create `playwright.yml`:
126 
127```yaml
128name: "playwright-tests"
129 
130on:
131 push:
132 branches: [main, dev]
133 pull_request:
134 branches: [main, dev]
135 
136jobs:
137 test:
138 timeout-minutes: 60
139 runs-on: ubuntu-latest
140 steps:
141 - uses: actions/checkout@v4
142 - uses: actions/setup-node@v4
143 with:
144 node-version: lts/*
145 - name: "install-dependencies"
146 run: npm ci
147 - name: "install-playwright-browsers"
148 run: npx playwright install --with-deps
149 - name: "run-playwright-tests"
150 run: npx playwright test
151 - uses: actions/upload-artifact@v4
152 if: ${{ !cancelled() }}
153 with:
154 name: "playwright-report"
155 path: playwright-report/
156 retention-days: 30
157```
158 
159If `.gitlab-ci.yml` exists, add a Playwright stage instead.
160 
161### 7. Update `.gitignore`
162 
163Append if not already present:
164 
165```
166/test-results/
167/playwright-report/
168/blob-report/
169/playwright/.cache/
170```
171 
172### 8. Add npm Scripts
173 
174Add to `package.json` scripts:
175 
176```json
177{
178 "test:e2e": "playwright test",
179 "test:e2e:ui": "playwright test --ui",
180 "test:e2e:debug": "playwright test --debug"
181}
182```
183 
184### 9. Verify Setup
185 
186Run the example test:
187 
188```bash
189npx playwright test
190```
191 
192Report the result. If it fails, diagnose and fix before completing.
193 
194## Output
195 
196Confirm what was created:
197- Config file path and key settings
198- Test directory and example test
199- CI workflow (if applicable)
200- npm scripts added
201- How to run: `npx playwright test` or `npm run test:e2e`
202 
View all files on GitHub →

Details

Updated
Aug 30, 2026
License
MIT
Stars on the repo
★ 26,349
Checked
Source
alirezarezvani/claude-skills ↗
Creator
alirezarezvani · 363 listings
View creator

Similar skills

See all →
Skill29 production-ready scripts for iOS app testing, buildingIos simulator skillconorluddy/ios-simulator-skill · by conorluddy29 production-ready scripts for iOS app testing, building, and automation. Provides semantic UI navigation, build automation, accessibility testing, and simulator lifecycle management. Optimized for AI agents with minimal token output.★ 1.3k GitHub starsSkillMoAI unified orchestrator for autonomous developmentmodu-ai/moai-adk · by modu-aiMoAI unified orchestrator for autonomous development. Routes natural language or subcommands (plan, run, sync, project, fix, loop, mx, feedback, review, clean, codemaps, gate, e2e, harness, goal, gtd, todo) to specialized agents.★ 1.2k GitHub starsSkillWrite Android unit, Compose UI, and Hilt-integrated testsAndroid Testing StandardsHoangNguyen0403/agent-skills-standard · by HoangNguyen0403Write Android unit, Compose UI, and Hilt-integrated tests. Use when designing test behavior with MockK or coroutine test utilities; defer database/WorkManager-specific recipes to the owning feature skill.★ 569 GitHub starsSkillImplementing any feature or bugfixTest-Driven Development (TDD)obra/superpowers · by obraUse when implementing any feature or bugfix, before writing implementation code★ 290k GitHub starsSkillToolkit for interacting with and testing local webWebapp testinganthropics/skills · by anthropicsToolkit for interacting with and testing local web applications using Playwright. Supports verifying frontend functionality, debugging UI behavior, capturing browser screenshots, and viewing browser logs.★ 178k GitHub starsPromptGuide to fixing bugs using a test-first approachTest first bug fixing approachf/prompts.chat · by Ilker UlusoyGuide to fixing bugs using a test-first approach, ensuring code reliability through systematic testing and implementation.New listing

More from alirezarezvani

SkillResume a paused experiment/ar:ar-resume — Resume Experimentalirezarezvani/claude-skills · by alirezarezvaniResume a paused experiment. Checkout the experiment branch, read results history, continue iterating. Use when the user runs /ar:ar-resume or asks to pick up a previously started autoresearch experiment.★ 26.3k GitHub starsSkillShow experiment dashboard with results, active loops/ar:ar-status — Experiment Dashboardalirezarezvani/claude-skills · by alirezarezvaniShow experiment dashboard with results, active loops, and progress. Use when the user runs /ar:ar-status or asks how an autoresearch experiment is going.★ 26.3k GitHub starsSkillStart an autonomous experiment loop with user-selected/ar:loop — Autonomous Experiment Loopalirezarezvani/claude-skills · by alirezarezvaniStart an autonomous experiment loop with user-selected interval (10min, 1h, daily, weekly, monthly). Uses CronCreate for scheduling. Use when the user runs /ar:loop or asks to run an autoresearch experiment continuously on a schedule.★ 26.3k GitHub starsSkillRun a single experiment iteration/ar:run — Single Experiment Iterationalirezarezvani/claude-skills · by alirezarezvaniRun a single experiment iteration. Edit the target file, evaluate, keep or discard. Use when the user runs /ar:run or asks for one manual autoresearch iteration.★ 26.3k GitHub starsSkillSet up a new autoresearch experiment interactively/ar:setup — Create New Experimentalirezarezvani/claude-skills · by alirezarezvaniSet up a new autoresearch experiment interactively. Collects domain, target file, eval command, metric, direction, and evaluator. Use when the user runs /ar:setup or asks to start optimizing a file with the autoresearch loop.★ 26.3k GitHub starsSkill/cs:boardroom <brief/cs:boardroom — Multi-Role Boardroom Deliberationalirezarezvani/claude-skills · by alirezarezvani/cs:boardroom <brief> — 6-phase multi-role deliberation across the C-suite with Phase 2 isolation, critic pre-screen, and synthesis. Outputs a board memo. Use when a decision spans multiple executive domains — e.g. a pricing change touching finance, positioning, and product, or a raise-vs-cut runway call.★ 26.3k GitHub stars