Complete Claude Code plugin with: - 9 skills (/pw:init, generate, review, fix, migrate, coverage, testrail, browserstack, report) - 3 specialized agents (test-architect, test-debugger, migration-planner) - 55 test case templates across 11 categories (auth, CRUD, checkout, search, forms, dashboard, settings, onboarding, notifications, API, accessibility) - TestRail MCP server (TypeScript) — 8 tools for bidirectional sync - BrowserStack MCP server (TypeScript) — 7 tools for cross-browser testing - Smart hooks (auto-validate tests, auto-detect Playwright projects) - 6 curated reference docs (golden rules, locators, assertions, fixtures, pitfalls, flaky tests) - Leverages Claude Code built-ins (/batch, /debug, Explore subagent) - Zero-config for core features; TestRail/BrowserStack via env vars - Both TypeScript and JavaScript support throughout Co-authored-by: Leo <leo@openclaw.ai>
3.6 KiB
3.6 KiB
Playwright Pro — Agent Context
You are working in a project with the Playwright Pro plugin installed. Follow these rules for all test-related work.
Golden Rules (Non-Negotiable)
getByRole()over CSS/XPath — resilient to markup changes, mirrors how users see the page- Never
page.waitForTimeout()— useexpect(locator).toBeVisible()orpage.waitForURL() - Web-first assertions —
expect(locator)auto-retries;expect(await locator.textContent())does not - Isolate every test — no shared state, no execution-order dependencies
baseURLin config — zero hardcoded URLs in tests- Retries:
2in CI,0locally — surface flakiness where it matters - Traces:
'on-first-retry'— rich debugging without CI slowdown - Fixtures over globals — share state via
test.extend(), not module-level variables - One behavior per test — multiple related
expect()calls are fine - Mock external services only — never mock your own app
Locator Priority
Always use the first option that works:
page.getByRole('button', { name: 'Submit' }) // 1. Role (default)
page.getByLabel('Email address') // 2. Label (form fields)
page.getByText('Welcome back') // 3. Text (non-interactive)
page.getByPlaceholder('Search...') // 4. Placeholder
page.getByAltText('Company logo') // 5. Alt text (images)
page.getByTitle('Close dialog') // 6. Title attribute
page.getByTestId('checkout-summary') // 7. Test ID (last semantic)
page.locator('.legacy-widget') // 8. CSS (last resort)
How to Use This Plugin
Generating Tests
When generating tests, always:
- Use the
Exploresubagent to scan the project structure first - Check
playwright.config.tsfortestDir,baseURL, and project settings - Load relevant templates from
templates/directory - Match the project's language (check for
tsconfig.json→ TypeScript, else JavaScript) - Place tests in the configured
testDir(default:tests/ore2e/) - Include a descriptive test name that explains the behavior being verified
Reviewing Tests
When reviewing, check against:
- All 10 golden rules above
- The anti-patterns in
skills/review/anti-patterns.md - Missing edge cases (empty state, error state, loading state)
- Proper use of fixtures for shared setup
Fixing Flaky Tests
When fixing flaky tests:
- Categorize first: timing, isolation, environment, or infrastructure
- Use
npx playwright test <file> --repeat-each=10to reproduce - Use
--trace=onfor every attempt - Apply the targeted fix from
skills/fix/flaky-taxonomy.md
Using Built-in Commands
Leverage Claude Code's built-in capabilities:
- Large migrations: Use
/batchfor parallel file-by-file conversion - Post-generation cleanup: Use
/simplifyafter generating a test suite - Debugging sessions: Use
/debugalongside/pw:fixfor trace analysis - Code review: Use
/reviewfor general code quality,/pw:reviewfor Playwright-specific
Integrations
- TestRail: Configured via
TESTRAIL_URL,TESTRAIL_USER,TESTRAIL_API_KEYenv vars - BrowserStack: Configured via
BROWSERSTACK_USERNAME,BROWSERSTACK_ACCESS_KEYenv vars - Both are optional. The plugin works fully without them.
File Conventions
- Test files:
*.spec.tsor*.spec.js - Page objects:
*.page.tsin apages/directory - Fixtures:
fixtures.tsorfixtures/directory - Test data:
test-data/directory with JSON/factory files