Review Playwright Tests

Review Playwright tests for quality.

How to use it

Claude Code
  1. Run the line below. It pulls the whole folder into ~/.claude/skills/pw-review, including the files SKILL.md points to.
  2. Describe your job in plain words. Claude Code follows the skill from there.
Claude Code — installs the whole folder, not just SKILL.md
npx degit alirezarezvani/claude-skills/engineering-team/playwright-pro/skills/pw-review#main ~/.claude/skills/pw-review

For one project only, change the path to .claude/skills/pw-review. This skill also uses anti-patterns.md — copying SKILL.md alone won't be enough. See the folder on GitHub.

Claude (web or desktop app)
  1. On this page open ⋯ → Download .md.
  2. Save it as SKILL.md in a folder, zip the folder, then Customize → Skills → + → Create skill → Upload a skill.
  3. Pick the file and Save. Claude shows the name and description and runs a security scan.
  4. Check the skill is switched on.
  5. Start a new chat and describe your job in plain words. The AI follows the skill from there.
ChatGPT or another app
  1. ChatGPT: make a Project and paste it into Instructions.
  2. Neither? Paste it at the top of a new chat — it works for that chat.
Not working?
  • Check which app you pasted it into — the steps above name the right one.
  • Some skills need the paid tier of Claude or ChatGPT.
Step-by-step guide with screenshots · Ask in the forum

Paste into Claude, ChatGPT or Cursor.

Source of Review Playwright Tests

Show the full text103 lines
namedescription
pw-review>- Review Playwright tests for quality. Use when user says "review tests", check test quality", "audit tests", "improve tests", "test code review", or "playwright best practices check".

Review Playwright Tests

Systematically review Playwright test files for anti-patterns, missed best practices, and coverage gaps.

Input

$ARGUMENTS can be:

  • A file path: review that specific test file
  • A directory: review all test files in the directory
  • Empty: review all tests in the project's testDir

Steps

1. Gather Context
  • Read playwright.config.ts for project settings
  • List all *.spec.ts / *.spec.js files in scope
  • If reviewing a single file, also check related page objects and fixtures
2. Check Each File Against Anti-Patterns

Load anti-patterns.md from this skill directory. Check for all 20 anti-patterns.

Critical (must fix):

  1. waitForTimeout() usage
  2. Non-web-first assertions (expect(await ...))
  3. Hardcoded URLs instead of baseURL
  4. CSS/XPath selectors when role-based exists
  5. Missing await on Playwright calls
  6. Shared mutable state between tests
  7. Test execution order dependencies

Warning (should fix): 8. Tests longer than 50 lines (consider splitting) 9. Magic strings without named constants 10. Missing error/edge case tests 11. page.evaluate() for things locators can do 12. Nested test.describe() more than 2 levels deep 13. Generic test names ("should work", "test 1")

Info (consider): 14. No page objects for pages with 5+ locators 15. Inline test data instead of factory/fixture 16. Missing accessibility assertions 17. No visual regression tests for UI-heavy pages 18. Console error assertions not checked 19. Network idle waits instead of specific assertions 20. Missing test.describe() grouping

3. Score Each File

Rate 1-10 based on:

  • 9-10: Production-ready, follows all golden rules
  • 7-8: Good, minor improvements possible
  • 5-6: Functional but has anti-patterns
  • 3-4: Significant issues, likely flaky
  • 1-2: Needs rewrite
4. Generate Review Report

For each file:

## <filename> — Score: X/10

### Critical
- Line 15: `waitForTimeout(2000)` → use `expect(locator).toBeVisible()`
- Line 28: CSS selector `.btn-submit` → `getByRole('button', { name: "submit" })`

### Warning
- Line 42: Test name "test login" → "should redirect to dashboard after login"

### Suggestions
- Consider adding error case: what happens with invalid credentials?
5. For Project-Wide Review

If reviewing an entire test suite:

  • Spawn sub-agents per file for parallel review (up to 5 concurrent)
  • Or use /batch for very large suites
  • Aggregate results into a summary table
6. Offer Fixes

For each critical issue, provide the corrected code. Ask user: "Apply these fixes? [Yes/No]"

If yes, apply all fixes using Edit tool.

Output

  • File-by-file review with scores
  • Summary: total files, average score, critical issue count
  • Actionable fix list
  • Coverage gaps identified (pages/features with no tests)
1---
2name: "pw-review"
3description: >-
4 Review Playwright tests for quality. Use when user says "review tests",
5 "check test quality", "audit tests", "improve tests", "test code review",
6 or "playwright best practices check".
7---
8 
9# Review Playwright Tests
10 
11Systematically review Playwright test files for anti-patterns, missed best practices, and coverage gaps.
12 
13## Input
14 
15`$ARGUMENTS` can be:
16- A file path: review that specific test file
17- A directory: review all test files in the directory
18- Empty: review all tests in the project's `testDir`
19 
20## Steps
21 
22### 1. Gather Context
23 
24- Read `playwright.config.ts` for project settings
25- List all `*.spec.ts` / `*.spec.js` files in scope
26- If reviewing a single file, also check related page objects and fixtures
27 
28### 2. Check Each File Against Anti-Patterns
29 
30Load `anti-patterns.md` from this skill directory. Check for all 20 anti-patterns.
31 
32**Critical (must fix):**
331. `waitForTimeout()` usage
342. Non-web-first assertions (`expect(await ...)`)
353. Hardcoded URLs instead of `baseURL`
364. CSS/XPath selectors when role-based exists
375. Missing `await` on Playwright calls
386. Shared mutable state between tests
397. Test execution order dependencies
40 
41**Warning (should fix):**
428. Tests longer than 50 lines (consider splitting)
439. Magic strings without named constants
4410. Missing error/edge case tests
4511. `page.evaluate()` for things locators can do
4612. Nested `test.describe()` more than 2 levels deep
4713. Generic test names ("should work", "test 1")
48 
49**Info (consider):**
5014. No page objects for pages with 5+ locators
5115. Inline test data instead of factory/fixture
5216. Missing accessibility assertions
5317. No visual regression tests for UI-heavy pages
5418. Console error assertions not checked
5519. Network idle waits instead of specific assertions
5620. Missing `test.describe()` grouping
57 
58### 3. Score Each File
59 
60Rate 1-10 based on:
61- **9-10**: Production-ready, follows all golden rules
62- **7-8**: Good, minor improvements possible
63- **5-6**: Functional but has anti-patterns
64- **3-4**: Significant issues, likely flaky
65- **1-2**: Needs rewrite
66 
67### 4. Generate Review Report
68 
69For each file:
70```
71## <filename> — Score: X/10
72 
73### Critical
74- Line 15: `waitForTimeout(2000)` → use `expect(locator).toBeVisible()`
75- Line 28: CSS selector `.btn-submit` → `getByRole('button', { name: "submit" })`
76 
77### Warning
78- Line 42: Test name "test login" → "should redirect to dashboard after login"
79 
80### Suggestions
81- Consider adding error case: what happens with invalid credentials?
82```
83 
84### 5. For Project-Wide Review
85 
86If reviewing an entire test suite:
87- Spawn sub-agents per file for parallel review (up to 5 concurrent)
88- Or use `/batch` for very large suites
89- Aggregate results into a summary table
90 
91### 6. Offer Fixes
92 
93For each critical issue, provide the corrected code. Ask user: "Apply these fixes? [Yes/No]"
94 
95If yes, apply all fixes using `Edit` tool.
96 
97## Output
98 
99- File-by-file review with scores
100- Summary: total files, average score, critical issue count
101- Actionable fix list
102- Coverage gaps identified (pages/features with no tests)
103 

Discussion