skills/playwright-testing/SKILL.md
Playwright testing workflows, templates, and tips for stable, non-flaky E2E tests in dev and CI environments. Use when writing Playwright specs for critical user flows (auth, navigation, features).
npx skillsauth add bkinsey808/songshare-effect playwright-testingInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Requires: file-read, terminal (test runner). No network access needed.
Use this skill when:
e2e/.Execution workflow:
npm run test:e2e:dev (or targeted Playwright command) before finalizing.Output requirements:
What this skill does
When to use
Step-by-step
npm run dev:all) for local test development.authenticateTestUser() and other helpers from e2e/utils when validating authenticated flows.await page.waitForTimeout(HYDRATION_WAIT_MS) where HYDRATION_WAIT_MS is a named constant from e2e/utils. This deliberate hydration wait is the one acceptable use of waitForTimeout — it uses a shared constant, not a magic number, and accounts for React Compiler hydration time.getByRole) and regex text matches for stability.npm run test:e2e:dev for running tests in dev mode and npx playwright test for CI or production checks.// BAD: Too specific, breaks if CSS changes
await page.locator("body > div.container > section > button.submit-btn").click();
✅ Better: Use semantic locators:
// GOOD: Accessible and stable
await page.getByRole("button", { name: /submit/i }).click();
Exception: HYDRATION_WAIT_MS from e2e/utils is permitted — it's a project constant for React hydration, not a magic number.
// BAD: Magic number timeout — flaky in CI
await page.waitForTimeout(500);
await page.click("button");
✅ Better: Wait for element to be ready:
// GOOD: Waits up to 30s for button to be enabled
await page.getByRole("button", { name: /submit/i }).isEnabled();
await page.getByRole("button", { name: /submit/i }).click();
Run these to validate Playwright tests:
# Run tests in dev mode (slow, interactive)
npm run test:e2e:dev
# Run tests in CI mode (fast, headless)
npx playwright test
# Run a single test file
npx playwright test e2e/specs/auth.spec.ts
# Run tests matching a pattern
npx playwright test -g "login"
# Debug a test
npx playwright test --debug e2e/specs/auth.spec.ts
# View test report
npx playwright show-report
docs/ai/rules.md.unit-test-best-practices.authentication-system.tools
Zustand state management patterns for this project — store creation, selectors, Immer middleware, async actions with loading states, devtools, persist, and testing. Use when authoring or editing Zustand stores (use*Store files) or components that subscribe to stores. Do NOT use for React component structure or TypeScript-only utilities.
testing
How to write, update, or split skill files in this repo. Use when creating a new SKILL.md, updating an existing one, or deciding whether to put content in a skill vs. docs/.
development
Complete guide for testing React hooks — renderHook, Documentation by Harness, installStore, fixtures, subscription patterns, lint/compiler traps, and pre-completion checklist. Read docs/testing/unit-test-hook-best-practices.md for the full reference.
development
Vitest unit test authoring for this repo — setup, mocking, API handler testing, and common pitfalls for non-hook code. Use when the user asks to add, update, fix, or review unit tests for utilities, components, API handlers, or scripts. Do NOT use for React hook tests — load unit-test-hook-best-practices instead.