Playwright Project Setup
Initialize Playwright Project

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)
npx skills add alirezarezvani/claude-skills --skill pw-init -g -a claude-codemkdir -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-initNew-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" -ForceConnects with Agent Alley MCP · agentalley.io/mcp
Files included
SKILL.md4.6 KB
Read the files here
alirezarezvani/
Shared references2SKILL.md reads these from elsewhere in the repo. Not in the ZIP.
- package.jsonengineering-team/playwright-pro/integrations/browserstack-mcp/400 B
- tsconfig.jsonengineering-team/playwright-pro/integrations/browserstack-mcp/284 B
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.jsonfor framework (React, Next.js, Vue, Angular, Svelte) - Check for
tsconfig.json→ use TypeScript; otherwise JavaScript - Check if Playwright is already installed (
@playwright/testin 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
baseURLtohttp://localhost:5173 - Change
webServer.commandtonpm run dev
Vue/Nuxt:
- Change
baseURLtohttp://localhost:3000 - Change
webServer.commandtonpm run dev
Angular:
- Change
baseURLtohttp://localhost:4200 - Change
webServer.commandtonpm run start
No framework detected:
- Omit
webServerblock - Set
baseURLfrom 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 testornpm run test:e2e
| 1 | |
| 2 | name "pw-init" |
| 3 | description >- |
| 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 | |
| 11 | Set 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 | |
| 17 | Use 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 | |
| 27 | If not already installed: |
| 28 | |
| 29 | |
| 30 | npm init playwright@latest -- --quiet |
| 31 | |
| 32 | |
| 33 | Or if the user prefers manual setup: |
| 34 | |
| 35 | |
| 36 | npm install -D @playwright/test |
| 37 | npx playwright install --with-deps chromium |
| 38 | |
| 39 | |
| 40 | ### 3. Generate `playwright.config.ts` |
| 41 | |
| 42 | Adapt to the detected framework: |
| 43 | |
| 44 | **Next.js:** |
| 45 | |
| 46 | import { defineConfig, devices } from '@playwright/test'; |
| 47 | |
| 48 | export 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 | |
| 95 | e2e/ |
| 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 | |
| 108 | import { test, expect } from '@playwright/test'; |
| 109 | |
| 110 | test.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 | |
| 125 | If `.github/workflows/` exists, create `playwright.yml`: |
| 126 | |
| 127 | |
| 128 | name: "playwright-tests" |
| 129 | |
| 130 | on: |
| 131 | push: |
| 132 | branches: [main, dev] |
| 133 | pull_request: |
| 134 | branches: [main, dev] |
| 135 | |
| 136 | jobs: |
| 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 | |
| 159 | If `.gitlab-ci.yml` exists, add a Playwright stage instead. |
| 160 | |
| 161 | ### 7. Update `.gitignore` |
| 162 | |
| 163 | Append 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 | |
| 174 | Add to `package.json` scripts: |
| 175 | |
| 176 | |
| 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 | |
| 186 | Run the example test: |
| 187 | |
| 188 | |
| 189 | npx playwright test |
| 190 | |
| 191 | |
| 192 | Report the result. If it fails, diagnose and fix before completing. |
| 193 | |
| 194 | ## Output |
| 195 | |
| 196 | Confirm 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 |
Details
- Updated
- Aug 30, 2026
- License
- MIT
- Stars on the repo
- ★ 26,349
- Checked
- Source
- alirezarezvani/claude-skills ↗
- Creator
- alirezarezvani · 363 listings
Similar skills
See all →
SkilliOS Simulator Testing Scripts
SkillMoAI Autonomous Orchestrator
SkillAndroid Test Writer
AgentVibe Testing
SkillFeature Testing Framework
SkillWeb App TesterMore from alirezarezvani
SkillExperiment Resume Tool
SkillExperiment Dashboard Viewer
SkillAutonomous Experiment Runner
SkillSingle Experiment Iterator
SkillAutoresearch Experiment Setup
SkillExecutive Boardroom Deliberator