Review Playwright Tests
Review Playwright tests for quality.
How to use it
Claude Code
- Run the line below. It pulls the whole folder into
~/.claude/skills/pw-review, including the files SKILL.md points to. - Describe your job in plain words. Claude Code follows the skill from there.
npx degit alirezarezvani/claude-skills/engineering-team/playwright-pro/skills/pw-review#main ~/.claude/skills/pw-reviewFor 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)
- On this page open ⋯ → Download .md.
- Save it as SKILL.md in a folder, zip the folder, then Customize → Skills → + → Create skill → Upload a skill.
- Pick the file and Save. Claude shows the name and description and runs a security scan.
- Check the skill is switched on.
- Start a new chat and describe your job in plain words. The AI follows the skill from there.
ChatGPT or another app
- ChatGPT: make a Project and paste it into Instructions.
- 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.
Paste into Claude, ChatGPT or Cursor.
Source of Review Playwright Tests
Show the full text103 lines
| name | description |
|---|---|
| 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.tsfor project settings - List all
*.spec.ts/*.spec.jsfiles 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):
waitForTimeout()usage- Non-web-first assertions (
expect(await ...)) - Hardcoded URLs instead of
baseURL - CSS/XPath selectors when role-based exists
- Missing
awaiton Playwright calls - Shared mutable state between tests
- 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
/batchfor 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 | |
| 2 | name "pw-review" |
| 3 | description >- |
| 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 | |
| 11 | Systematically 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 | |
| 30 | Load `anti-patterns.md` from this skill directory. Check for all 20 anti-patterns. |
| 31 | |
| 32 | **Critical (must fix):** |
| 33 | `waitForTimeout()` usage |
| 34 | Non-web-first assertions (`expect(await ...)`) |
| 35 | Hardcoded URLs instead of `baseURL` |
| 36 | CSS/XPath selectors when role-based exists |
| 37 | Missing `await` on Playwright calls |
| 38 | Shared mutable state between tests |
| 39 | Test execution order dependencies |
| 40 | |
| 41 | **Warning (should fix):** |
| 42 | Tests longer than 50 lines (consider splitting) |
| 43 | Magic strings without named constants |
| 44 | Missing error/edge case tests |
| 45 | `page.evaluate()` for things locators can do |
| 46 | Nested `test.describe()` more than 2 levels deep |
| 47 | Generic test names ("should work", "test 1") |
| 48 | |
| 49 | **Info (consider):** |
| 50 | No page objects for pages with 5+ locators |
| 51 | Inline test data instead of factory/fixture |
| 52 | Missing accessibility assertions |
| 53 | No visual regression tests for UI-heavy pages |
| 54 | Console error assertions not checked |
| 55 | Network idle waits instead of specific assertions |
| 56 | Missing `test.describe()` grouping |
| 57 | |
| 58 | ### 3. Score Each File |
| 59 | |
| 60 | Rate 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 | |
| 69 | For 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 | |
| 86 | If 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 | |
| 93 | For each critical issue, provide the corrected code. Ask user: "Apply these fixes? [Yes/No]" |
| 94 | |
| 95 | If 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
Browse more free Claude skills.