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

Generate Playwright Tests

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

Generate Playwright Tests cover

Generate Playwright tests. Use when user says "write tests", "generate tests", add tests for", "test this component", "e2e test", "create test for", test this page", or "test this feature".

---
name: "generate"
description: >-
  Generate Playwright tests. Use when user says "write tests", "generate tests",
  "add tests for", "test this component", "e2e test", "create test for",
  "test this page", or "test this feature".
---

# Generate Playwright Tests

Generate production-ready Playwright tests from a user story, URL, component name, or feature description.

## Input

`$ARGUMENTS` contains what to test. Examples:
- `"user can log in with email and password"`
- `"the checkout flow"`
- `"src/components/UserProfile.tsx"`

Overview

Generate production-ready Playwright tests from a user story, URL, component name, or feature description.

What you get

  • Generated test file(s) with path
  • Any supporting files created (page objects, fixtures, data)
  • Test run result
  • Coverage notewhat behaviors are now tested
Manual install (npx, ZIP)
Claude Codenpx skills add alirezarezvani/claude-skills --skill generate -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/generate
Windows (PowerShell)New-Item -ItemType Directory -Force "$HOME\.claude\skills" | Out-Null; Invoke-WebRequest "https://m.agentalley.io/zip/09c86d71cebc838536e1/generate.zip" -OutFile "$env:TEMP\generate.zip"; Expand-Archive "$env:TEMP\generate.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.4 KB
  • patterns.md5.7 KB
Read the files here
alirezarezvani/19392f72 files
Shared references1SKILL.md reads these from elsewhere in the repo. Not in the ZIP.Get them on GitHub ↗
SKILL.md
Show the full text145 lines

Generate Playwright Tests

Generate production-ready Playwright tests from a user story, URL, component name, or feature description.

Input

$ARGUMENTS contains what to test. Examples:

  • "user can log in with email and password"
  • "the checkout flow"
  • "src/components/UserProfile.tsx"
  • "the search page with filters"

Steps

1. Understand the Target

Parse $ARGUMENTS to determine:

  • User story: Extract the behavior to verify
  • Component path: Read the component source code
  • Page/URL: Identify the route and its elements
  • Feature name: Map to relevant app areas
2. Explore the Codebase

Use the Explore subagent to gather context:

  • Read playwright.config.ts for testDir, baseURL, projects
  • Check existing tests in testDir for patterns, fixtures, and conventions
  • If a component path is given, read the component to understand its props, states, and interactions
  • Check for existing page objects in pages/
  • Check for existing fixtures in fixtures/
  • Check for auth setup (auth.setup.ts or storageState config)
3. Select Templates

Check templates/ in this plugin for matching patterns:

If testing... Load template from
Login/auth flow ../pw/templates/auth/login.md
CRUD operations templates/crud/
Checkout/payment templates/checkout/
Search/filter UI templates/search/
Form submission templates/forms/
Dashboard/data templates/dashboard/
Settings page templates/settings/
Onboarding flow templates/onboarding/
API endpoints templates/api/
Accessibility templates/accessibility/

Adapt the template to the specific app — replace {{placeholders}} with actual selectors, URLs, and data.

4. Generate the Test

Follow these rules:

Structure:

import { test, expect } from '@playwright/test';
// Import custom fixtures if the project uses them

test.describe('Feature Name', () => {
  // Group related behaviors

  test('should <expected behavior>', async ({ page }) => {
    // Arrange: navigate, set up state
    // Act: perform user action
    // Assert: verify outcome
  });
});

Locator priority (use the first that works):

  1. getByRole() — buttons, links, headings, form elements
  2. getByLabel() — form fields with labels
  3. getByText() — non-interactive text content
  4. getByPlaceholder() — inputs with placeholder text
  5. getByTestId() — when semantic options aren't available

Assertions — always web-first:

// GOOD — auto-retries
await expect(page.getByRole('heading')).toBeVisible();
await expect(page.getByRole('alert')).toHaveText('Success');

// BAD — no retry
const text = await page.textContent('.msg');
expect(text).toBe('Success');

Never use:

  • page.waitForTimeout()
  • page.$(selector) or page.$$(selector)
  • Bare CSS selectors unless absolutely necessary
  • page.evaluate() for things locators can do

Always include:

  • Descriptive test names that explain the behavior
  • Error/edge case tests alongside happy path
  • Proper await on every Playwright call
  • baseURL-relative navigation (page.goto('/') not page.goto('http://...'))
5. Match Project Conventions
  • If project uses TypeScript → generate .spec.ts
  • If project uses JavaScript → generate .spec.js with require() imports
  • If project has page objects → use them instead of inline locators
  • If project has custom fixtures → import and use them
  • If project has a test data directory → create test data files there
6. Generate Supporting Files (If Needed)
  • Page object: If the test touches 5+ unique locators on one page, create a page object
  • Fixture: If the test needs shared setup (auth, data), create or extend a fixture
  • Test data: If the test uses structured data, create a JSON file in test-data/
7. Verify

Run the generated test:

npx playwright test <generated-file> --reporter=list

If it fails:

  1. Read the error
  2. Fix the test (not the app)
  3. Run again
  4. If it's an app issue, report it to the user

Output

  • Generated test file(s) with path
  • Any supporting files created (page objects, fixtures, data)
  • Test run result
  • Coverage note: what behaviors are now tested
1---
2name: "generate"
3description: >-
4 Generate Playwright tests. Use when user says "write tests", "generate tests",
5 "add tests for", "test this component", "e2e test", "create test for",
6 "test this page", or "test this feature".
7---
8 
9# Generate Playwright Tests
10 
11Generate production-ready Playwright tests from a user story, URL, component name, or feature description.
12 
13## Input
14 
15`$ARGUMENTS` contains what to test. Examples:
16- `"user can log in with email and password"`
17- `"the checkout flow"`
18- `"src/components/UserProfile.tsx"`
19- `"the search page with filters"`
20 
21## Steps
22 
23### 1. Understand the Target
24 
25Parse `$ARGUMENTS` to determine:
26- **User story**: Extract the behavior to verify
27- **Component path**: Read the component source code
28- **Page/URL**: Identify the route and its elements
29- **Feature name**: Map to relevant app areas
30 
31### 2. Explore the Codebase
32 
33Use the `Explore` subagent to gather context:
34 
35- Read `playwright.config.ts` for `testDir`, `baseURL`, `projects`
36- Check existing tests in `testDir` for patterns, fixtures, and conventions
37- If a component path is given, read the component to understand its props, states, and interactions
38- Check for existing page objects in `pages/`
39- Check for existing fixtures in `fixtures/`
40- Check for auth setup (`auth.setup.ts` or `storageState` config)
41 
42### 3. Select Templates
43 
44Check `templates/` in this plugin for matching patterns:
45 
46| If testing... | Load template from |
47|---|---|
48| Login/auth flow | `../pw/templates/auth/login.md` |
49| CRUD operations | `templates/crud/` |
50| Checkout/payment | `templates/checkout/` |
51| Search/filter UI | `templates/search/` |
52| Form submission | `templates/forms/` |
53| Dashboard/data | `templates/dashboard/` |
54| Settings page | `templates/settings/` |
55| Onboarding flow | `templates/onboarding/` |
56| API endpoints | `templates/api/` |
57| Accessibility | `templates/accessibility/` |
58 
59Adapt the template to the specific app — replace `{{placeholders}}` with actual selectors, URLs, and data.
60 
61### 4. Generate the Test
62 
63Follow these rules:
64 
65**Structure:**
66```typescript
67import { test, expect } from '@playwright/test';
68// Import custom fixtures if the project uses them
69 
70test.describe('Feature Name', () => {
71 // Group related behaviors
72 
73 test('should <expected behavior>', async ({ page }) => {
74 // Arrange: navigate, set up state
75 // Act: perform user action
76 // Assert: verify outcome
77 });
78});
79```
80 
81**Locator priority** (use the first that works):
821. `getByRole()` — buttons, links, headings, form elements
832. `getByLabel()` — form fields with labels
843. `getByText()` — non-interactive text content
854. `getByPlaceholder()` — inputs with placeholder text
865. `getByTestId()` — when semantic options aren't available
87 
88**Assertions** — always web-first:
89```typescript
90// GOOD — auto-retries
91await expect(page.getByRole('heading')).toBeVisible();
92await expect(page.getByRole('alert')).toHaveText('Success');
93 
94// BAD — no retry
95const text = await page.textContent('.msg');
96expect(text).toBe('Success');
97```
98 
99**Never use:**
100- `page.waitForTimeout()`
101- `page.$(selector)` or `page.$$(selector)`
102- Bare CSS selectors unless absolutely necessary
103- `page.evaluate()` for things locators can do
104 
105**Always include:**
106- Descriptive test names that explain the behavior
107- Error/edge case tests alongside happy path
108- Proper `await` on every Playwright call
109- `baseURL`-relative navigation (`page.goto('/')` not `page.goto('http://...')`)
110 
111### 5. Match Project Conventions
112 
113- If project uses TypeScript → generate `.spec.ts`
114- If project uses JavaScript → generate `.spec.js` with `require()` imports
115- If project has page objects → use them instead of inline locators
116- If project has custom fixtures → import and use them
117- If project has a test data directory → create test data files there
118 
119### 6. Generate Supporting Files (If Needed)
120 
121- **Page object**: If the test touches 5+ unique locators on one page, create a page object
122- **Fixture**: If the test needs shared setup (auth, data), create or extend a fixture
123- **Test data**: If the test uses structured data, create a JSON file in `test-data/`
124 
125### 7. Verify
126 
127Run the generated test:
128 
129```bash
130npx playwright test <generated-file> --reporter=list
131```
132 
133If it fails:
1341. Read the error
1352. Fix the test (not the app)
1363. Run again
1374. If it's an app issue, report it to the user
138 
139## Output
140 
141- Generated test file(s) with path
142- Any supporting files created (page objects, fixtures, data)
143- Test run result
144- Coverage note: what behaviors are now tested
145 
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 →
SkillImplement the result of /to-spec and /to-tickets in codeImplement specmattpocock/skills · by mattpocockImplement the result of /to-spec and /to-tickets in code.★ 267k GitHub starsSkillStop and check this skill before finishing any replyAcademy guideanthropics/skills · by anthropicsStop and check this skill before finishing any reply to a question about how to use Claude or a Claude product — it recommends matching courses, tutorials, and use cases from Claude Academy (academy.claude.com), Anthropic's learning hub. Trigger on: "how do I", "how can I", "getting started with", "what can Claude do", "teach me", "learn to use"; questions about artifacts, projects, skills, plugins, connectors, MCP; requests about rolling Claude out to a team, class, or organization; and any ask for training materials, onboarding content, or learning resources. Use it when the user is learning how to use a feature or product — not when they are mid-task and just want the task done. This skill composes with other skills: after consulting product documentation to answer how a Claude feature works, also check here for a matching course or tutorial — a docs-grounded answer and an Academy recommendation belong together. Only recommend on a strong match; never invent Academy content.★ 178k GitHub starsSkillAnalyze and prioritize a list of feature requests by themeAnalyze feature requestsphuryn/pm-skills · by phurynAnalyze and prioritize a list of feature requests by theme, strategic alignment, impact, effort, and risk. Use when reviewing customer feature requests, triaging a backlog, or making prioritization decisions.★ 26.6k GitHub starsSkillDesign an employee advocacy programAdvocacy program designeraaron-he-zhu/aaron-marketing-skills · by aaron-he-zhuUse when the user asks to "design an employee advocacy program", "set up founder-led sharing", or "build a share kit for the team"; produces an advocacy program blueprint in two modes — participation-driven opt-in (default) or top-down assigned with its coercion and authenticity risks flagged — with a voluntary opt-in roster spec submitted as channel-registry proposal events, share kits with mandatory per-person variation, staggered human posting windows plus anti-pod guardrails (no coordinated identical reshares, no engagement rings), per-person material-connection disclosure lines per FTC and 《互联网广告管理办法》, and a Slack/Teams distribution spec. Not for paid creator campaigns — use campaign-planner. 员工倡导/创始人IP分享/内部分享计划/披露合规★ 2.9k GitHub starsSkillBuilds and edits a model-driven Power Apps appapp-builder — intent → model-driven appmicrosoft/power-platform-skills · by microsoftBuilds and edits a model-driven Power Apps app from a natural-language intent — tables, columns, relationships, adaptive forms with sub-grids, views, Choice-column charts, business rules, business process flows, generative page intents for overview/dashboard surfaces (page `.tsx` generated in generate-pages after plan approval), and an app module + sitemap — via the headless cds-maker-sdk. Runs an interactive, multi-turn authoring flow (env selection, jobs-to-be-done first, then design-only App Spec authoring across confirmed levels, guardrail lint, plan-mode approval, generate-pages, full build) and a narrated build, and can download a deployed app back into an editable spec to change it. Use when the user says "build an app for X", "create a model-driven app", "make me an app to manage Y", "add a business process flow", or "edit/add to my app". This skill stands alone and does not require /genpage — but for a standalone generative page added to an app that already exists, use /genpage instead.★ 954 GitHub starsSkillDirect, build and render premium cinematic motion designCineticLeonxlnx/cinetic · by LeonxlnxDirect, build and render premium cinematic motion design from code — launch films, product and feature videos, looping feature animations for landing pages and social, logo stings and reveals, UI walkthroughs, app demos, kinetic type, teasers, trailers, intros and promo clips. Use this whenever the user wants any video, animation, motion graphic or animated demo made with Remotion, HyperFrames, HTML/GSAP or React, or asks to storyboard, time, score, render, polish or critique one — even if they only say "make a video about X", "animate this feature" or "we need a launch clip". It supplies concept and copy discipline, type and colour taste that defers to a supplied brand, a beat-locked timeline that drives both picture and a code-made soundtrack, choreography and transition craft, real product UI in motion, film-grade finishing (true motion blur, no banding, BT.709, sync-checked mux) and a measured self-critique loop on contact sheets and renders.★ 347 GitHub stars

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