Plan, implement, and debug frontend tests: unit/integration/E2E/visual/a11y. Use for Playwright/Cypress/Vitest/Jest/RTL, flaky test triage, CI stabilization, and canvas/WebGL games (Phaser) needing deterministic input + screenshot/state assertions.
Unlock reliable confidence fast: enable safe refactors by choosing the right test layer, making the app observable, and eliminating nondeterminism so failures are actionable.
Frontend tests fail for two reasons: the product is broken, or the test is lying. Your job is to maximize signal and minimize “test is lying”.
Before writing a test, ask:
setTimeout?Core principles:
Pick the test type by the cheapest layer that provides the needed confidence:
Use Playwright when you need “real browser” confidence:
window (read-only state + a few commands).waitForFunction-style readiness over sleep; gate on “scene ready” / “assets loaded” / “first frame rendered”.references/phaser-canvas-testing.md).If using the Playwright MCP tools (browser automation inside Codex), follow the same mindset:
browser_console_messages and browser_network_requests to catch silent failures.browser_evaluate to assert window.__TEST__ state and to set up deterministic mode.browser_take_screenshot for visual assertions after determinism is enforced.When a UI is dynamic, don’t guess selectors—recon first, then act:
Quick decision guide:
Task → Is it static HTML (no JS runtime needed)?
├─ Yes → read the HTML to find stable selectors/content, then automate
└─ No → treat as dynamic: run the app, wait for readiness, then inspect rendered state
networkidle can help for SPAs, but avoid it if the app uses websockets/polling.Common pitfall:
❌ Inspect/interact before the app is ready.
✅ Wait on an explicit ready signal (DOM marker or window.__TEST__.ready), not a sleep.
When the dev server isn’t already running, use the bundled helper as a black box:
python scripts/with_server.py --help first.Example:
python scripts/with_server.py --server "npm run dev" --port 5173 -- npm test
Date.now, timers), RNG, and animation loops.❌ Testing the wrong layer: E2E tests for pure logic. Better: unit tests for logic; reserve E2E for integration contracts.
❌ Testing implementation details: asserting DOM structure/classnames or internal engine objects. Better: assert user-meaningful outputs (text, navigation, score/HP changes) or a small stable test seam.
❌ Sleep-driven tests: wait 2s then click.
Better: wait on explicit readiness (DOM marker, event, window flag).
❌ Uncontrolled randomness: RNG/time-based behaviors in assertions. Better: seed RNG, freeze time, and assert stable invariants.
❌ Pixel snapshots without determinism (especially canvas/WebGL). Better: add deterministic mode first; then screenshot selectively.
❌ Snapshot explosion: hundreds of snapshots that no one can interpret. Better: keep snapshots targeted (critical screens); prefer specific assertions for behavior.
❌ Retries as a strategy: “just bump retries in CI”. Better: fix readiness and determinism; use retries only as temporary guardrails.
Vary the approach based on:
window.__TEST__ API, assert state; if not, stick to black-box input/output.You can make almost any frontend (including canvas/WebGL games) testable by adding a tiny, stable seam for readiness + state. This skill is meant to empower creative, high-signal testing rather than cargo-cult checklists. Aim for tests that are boring to maintain: deterministic, explicit about readiness, and rich in failure evidence. One reliable smoke test is the foundation; everything else compounds from there.
Read these only when needed:
references/playwright-mcp-cheatsheet.md: patterns for using Playwright MCP tools for assertions, waiting, and diagnostics.references/phaser-canvas-testing.md: deterministic mode + hooks for Phaser/canvas/WebGL games.references/flake-reduction.md: deeper flake triage and stabilization tactics.Use these scripts as black boxes (run --help first; don’t read source unless you must):
scripts/with_server.py: start/wait/stop one or more dev servers around a test command.scripts/imgdiff.py: lightweight screenshot diff helper (requires pip install pillow).npx skills add chongdashu/playwright-testing下载完整 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