Home / Market / pw review

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".

skill★ 309340 dlgithubMITInstall in CosmosUpstream Source

Documentation & Preview

--- name: "pw-review" description: >- 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:

Steps

1. Gather Context

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):

  1. Tests longer than 50 lines (consider splitting)
  2. Magic strings without named constants
  3. Missing error/edge case tests
  4. page.evaluate() for things locators can do
  5. Nested test.describe() more than 2 levels deep
  6. Generic test names ("should work", "test 1")

Info (consider):

  1. No page objects for pages with 5+ locators
  2. Inline test data instead of factory/fixture
  3. Missing accessibility assertions
  4. No visual regression tests for UI-heavy pages
  5. Console error assertions not checked
  6. Network idle waits instead of specific assertions
  7. Missing test.describe() grouping

3. Score Each File

Rate 1-10 based on:

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:

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