Use when writing or reviewing Playwright E2E tests - locator strategies, Page Object Model, auto-waiting, network interception, and WordPress/WooCommerce test helpers.
Resolve SKILL_DIR to the absolute directory containing this SKILL.md, as
shown by the current host, before using any bundled path below.
Before a shell command uses $SKILL_DIR, assign it in that command or replace
it with the resolved path. It is not a host-exported environment variable.
Playwright end-to-end testing patterns. For shared test quality principles (philosophy, smells, mocking decisions), see testing-patterns.
| Need | Reference File | Sections to Read |
|------|---------------|-----------------|
| Playwright + E2E patterns | $SKILL_DIR/../testing-patterns/references/playwright-patterns.md | Full file (~461L, manageable) |
| Behavior vs implementation | $SKILL_DIR/../testing-patterns/references/test-philosophy.md | ## The Fundamental Shift + ## Four Core Principles |
| Flaky/brittle tests | $SKILL_DIR/../testing-patterns/references/test-smells.md | ## The Six Major Test Smells (relevant subsection) |
| Mock usage decisions | $SKILL_DIR/../testing-patterns/references/mocking-strategies.md | ## The Mocking Decision Framework |
| Test layer strategy | $SKILL_DIR/../testing-patterns/references/test-layers.md | ## The Three Layers + ## Choosing the Right Layer |
How to read sections: Grep for heading to find line number, Read with offset+limit.
page.getByRole('button', { name: 'Submit' }) — accessible, resilientpage.getByLabel('Email') — form elementspage.getByText('Welcome') — visible contentpage.getByTestId('checkout-form') — explicit test hookspage.locator('.class') / #id — last resort, fragile| Use | Instead Of | Why |
|-----|-----------|-----|
| await expect(locator).toBeVisible() | page.waitForTimeout(2000) | Auto-waits, deterministic |
| page.getByRole() | page.locator('.btn') | Resilient to CSS changes |
| Page Object Model | Inline selectors | Reusable, single source of truth |
| page.route() for external APIs | Real HTTP calls | Fast, deterministic, no rate limits |
| Config-based URLs | http://localhost:8080 | Works across environments |
| toHaveScreenshot({ maxDiffPixelRatio: 0.01 }) | toMatchSnapshot() | Tolerates rendering differences |
| test.describe() grouping | Flat test structure | Logical organization |
| await before all assertions | Missing await | Playwright assertions are async |
| Pattern | Why Harmful | Fix |
|---------|------------|-----|
| CSS selectors as primary locators | Break on styling changes | Use role/label/text locators |
| page.waitForTimeout() | Arbitrary delay, flaky | Use expect(locator).toBeVisible() |
| Missing test isolation | Tests depend on prior state | beforeEach setup, clean state |
| Hardcoded URLs | Breaks across environments | Use config/env variables |
| No Page Object Model | Duplicated selectors | Extract to page object classes |
| Screenshot without tolerance | Pixel-perfect failures | Set maxDiffPixelRatio |
| Missing await before assertions | Silent assertion skip | Always await Playwright expects |
| page.evaluate() for assertions | Bypasses auto-waiting | Use Playwright locator assertions |
| No network interception | Flaky external calls | page.route() for third-party APIs |
this or the next page object for chainingnpx skills add vladolaru/e2e-testing-patterns下载完整 Skill 目录,包含 SKILL.md 及所有相关文件
Search for places (restaurants, cafes, etc.) via Google Places API proxy on localhost.
Interact with GitHub using the `gh` CLI. Use `gh issue`, `gh pr`, `gh run`, and `gh api` for issues, PRs, CI runs, and advanced queries.
Create or update AgentSkills. Use when designing, structuring, or packaging skills with scripts, references, and assets.
Start voice calls via the OpenClaw voice-call plugin.
Notion API for creating and managing pages, databases, and blocks.
Gemini CLI for one-shot Q&A, summaries, and generation.
Category:developer