Token导航 LogoToken导航TokenDH.com
研究检索操作浏览器github未标认证来源可访问许可证需确认审计通过

playwright-testingPlaywright 测试

Agent Skill

用于辅助测试设计、自动化测试、用例整理和回归验证。它适合让 Agent 编写单元测试、端到端测试、测试计划或根据失败日志定位问题。使用时需要确认项目测试框架、运行命令和夹具数据,避免为了通过测试而改坏真实逻辑;涉及浏览器或外部服务时,应区分本地模拟、测试环境和生产环境。

总安装

1,847

周安装

74

GitHub Stars

65

下载量

598
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:playwright-testing(Playwright 测试)
来源仓库:https://github.com/chongdashu/phaserjs-oakwoods
仓库路径:skills/playwright-testing
安装命令:
npx skills add https://github.com/chongdashu/phaserjs-oakwoods --skill playwright-testing
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/chongdashu/phaserjs-oakwoods --skill playwright-testing

简介

编写可靠的前端测试用例,覆盖用户关键风险点如资金、进度与数据丢失防护。

  • 选择最窄有效测试层(纯逻辑、UI 或全浏览器),消除时间、随机数等非确定性因素。
  • 使应用可观测、失败可复现,避免“假阳性”测试误导开发决策。
  • 适用于 Phaser 游戏或其他前端项目,需区分模拟环境与真实浏览器行为。
  • playwright-testing 属于研究检索类 Skill,可作为该场景下的辅助能力补充。

SKILL.md

Frontend Testing

Unlock reliable confidence fast: enable safe refactors by choosing the right test layer, making the app observable, and eliminating nondeterminism so failures are actionable.

Philosophy: Confidence Per Minute

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:

  • What user risk am I covering (money, progression, auth, data loss, crashes)?
  • What's the narrowest layer that catches this bug class (pure logic vs UI vs full browser)?
  • What nondeterminism exists (time, RNG, async loading, network, animations, fonts, GPU)?
  • What "ready" signal can I wait on besides setTimeout?
  • What should a failure print/screenshot so it's diagnosable in CI?

Core principles:

  1. Test the contract, not the implementation: assert stable user-meaningful outcomes and public seams.
  2. Prefer determinism over retries: make time/RNG/network controllable; remove flake at the source.
  3. Observe like a debugger: console errors, network failures, screenshots, and state dumps on failure.
  4. One critical flow first: a reliable smoke test beats 50 flaky tests.

Test Layer Decision Tree

Pick the cheapest layer that provides needed confidence:

LayerSpeedUse For
UnitFastestPure functions, reducers, validators, math, pathfinding, deterministic simulation
ComponentMediumUI behavior with mocked IO (React Testing Library, Vue Testing Library)
E2ESlowestCritical user flows across routing, storage, real bundling/runtime
VisualSpecializedLayout/pixel regressions; for canvas/WebGL, only after locking determinism

Quick Start: First Smoke Test

  1. Define 1 critical flow: "page loads → user can start → one key action works"
  2. Add a test seam to the app (see below)
  3. Choose runner: Playwright MCP for E2E, unit tests for logic
  4. Fail loudly: treat console errors and failed requests as test failures
  5. Stabilize: seed RNG, freeze time, fix viewport, disable animations

Concrete MCP Workflow: Testing a Game

Step-by-step sequence for testing a Phaser/canvas game:

1. mcp__playwright__browser_navigate
   → http://localhost:3000?test=1&seed=42

2. mcp__playwright__browser_evaluate
   → () => new Promise(r => { const c = () => window.__TEST__?.ready ? r(true) : setTimeout(c, 100); c(); })
   (Wait for game ready)

3. mcp__playwright__browser_console_messages
   → level: "error"
   (Fail if any errors)

4. mcp__playwright__browser_snapshot
   → Get UI state and refs

5. mcp__playwright__browser_click
   → element: "Start Button", ref: [from snapshot]

6. mcp__playwright__browser_evaluate
   → () => window.__TEST__.state()
   (Assert game state is correct)

7. mcp__playwright__browser_press_key
   → key: "ArrowRight" (or WASD for movement)

8. mcp__playwright__browser_evaluate
   → () => window.__TEST__.state().player.x
   (Verify movement happened)

9. mcp__playwright__browser_take_screenshot
   → filename: "gameplay-state.png"
   (Visual evidence after deterministic setup)

Recommended Test Seams

Add to the app for testability (read-only, stable, minimal):

window.__TEST__ = {
  ready: false,           // true after first interactive frame
  seed: null,             // current RNG seed
  sceneKey: null,         // current scene/route
  state: () => ({         // JSON-serializable snapshot
    scene: this.sceneKey,
    player: { x, y, hp },
    score: gameState.score,
    entities: entities.map(e => ({ id: e.id, type: e.type, x: e.x, y: e.y }))
  }),
  commands: {             // optional mutation commands
    reset: () => {},
    seed: (n) => {},
    skipIntro: () => {}
  }
};

Rule: Expose IDs + essential fields, not raw Phaser/engine objects.

Anti-Patterns to Avoid

Testing the wrong layer: E2E tests for pure logic *Why tempting*: "Let's just test everything through the browser" *Better*: Unit tests for logic; reserve E2E for integration contracts

Testing implementation details: Asserting DOM structure/classnames *Why tempting*: Easy to assert what you can see in DevTools *Better*: Assert user-meaningful outputs (text, score, HP changes)

Sleep-driven tests: wait 2s then click *Why tempting*: Simple and "works on my machine" *Better*: Wait on explicit readiness (DOM marker, window.__TEST__.ready)

Uncontrolled randomness: RNG/time in assertions *Why tempting*: "The game uses random, so the test should too" *Better*: Seed RNG (?seed=42), freeze time, assert stable invariants

Pixel snapshots without determinism: Canvas screenshots that flake *Why tempting*: "I'll catch visual bugs automatically" *Better*: Deterministic mode first; then screenshot at known stable frames

Retries as a strategy: "Just bump retries to 3" *Why tempting*: Quick fix that makes CI green *Better*: Fix the flake source; retries hide real problems

Debugging Failed Tests

When a test fails, gather evidence in this order:

  1. Console errors: mcp__playwright__browser_console_messages({level: "error"})
  2. Network failures: mcp__playwright__browser_network_requests() → check for non-2xx
  3. Screenshot: mcp__playwright__browser_take_screenshot() → visual state at failure
  4. App state: mcp__playwright__browser_evaluate({function: "() => window.__TEST__.state()"})
  5. Classify the flake (see references/flake-reduction.md):

- Readiness? → add explicit wait - Timing? → control animation/physics - Environment? → lock viewport/DPR - Data? → isolate test data

Graduation Criteria: When Is Testing "Enough"?

Minimum viable test suite:

  • 1 smoke test that proves the app loads and primary action works
  • Test seam exists (window.__TEST__ with ready flag and state)
  • Deterministic mode for canvas/games (?test=1 enables seeding)
  • Console errors fail tests (no silent failures)
  • CI runs tests on every push

Level up when:

  • Critical paths (auth, payment, save/load) have dedicated E2E
  • Unit tests cover complex logic (pathfinding, damage calc, state machines)
  • Visual regression on key screens (menu, HUD) with locked determinism

Visual Regression with imgdiff.py

For pixel comparison of screenshots:

# Compare baseline to current
python scripts/imgdiff.py baseline.png current.png --out diff.png

# Allow small tolerance (anti-aliasing differences)
python scripts/imgdiff.py baseline.png current.png --max-rms 2.0

Exit codes: 0 = identical, 1 = different, 2 = error

UI Slicing Regressions (Nine-Slice / Ribbons / Bars)

Canvas UI issues (panel seams, segmented ribbons, invisible HUD fills) are best caught with a dedicated UI harness instead of the full gameplay flow.

  1. Build a simple test.html/scene that loads *only* the UI assets.
  2. Render raw slices next to assembled panels (multi-size), and include ribbon/bars with both “raw crop + scale” and “stitched multi-slice” views.
  3. Expose window.__TEST__ with .commands.showTest(n) so Playwright can toggle each mode deterministically.
  4. Capture targeted screenshots (panels, ribbons, bars) and diff them in CI.

See references/phaser-canvas-testing.md for the deterministic setup + screenshot workflow.

Variation Guidance

Adapt approach based on context:

  • DOM app: Standard Playwright selectors, wait for text/elements
  • Canvas game: Test seams mandatory, wait via window.__TEST__.ready
  • Hybrid: DOM for menus, test seams for gameplay
  • CI-only GPU: May need software rendering flags or skip visual tests
  • UI slicing regressions: For nine-slice/ribbon/bar artifacts, prefer a small UI harness scene/page with deterministic modes and targeted screenshots (references/phaser-canvas-testing.md).

Bundled Resources

Read these when needed:

  • references/playwright-mcp-cheatsheet.md: Detailed MCP tool patterns
  • references/phaser-canvas-testing.md: Deterministic mode for Phaser games
  • references/flake-reduction.md: Flake classification and fixes

Remember

You can make almost any frontend (including canvas/WebGL games) testable by adding a tiny, stable seam for readiness + state. One reliable smoke test is the foundation. Aim for tests that are boring to maintain: deterministic, explicit about readiness, and rich in failure evidence. The goal is confidence, not coverage numbers.

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Codex

38.6%
按下载量换算231

Claude

28.76%
按下载量换算172

Cursor

18.54%
按下载量换算111

Gemini CLI

8.69%
按下载量换算52

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

操作浏览器

该 Skill 可能涉及浏览器控制能力,使用时可能读取或操作网页内容,需要在受控环境中确认权限边界。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。当前只有一个来源,正式发布前建议补源仓库或其他目录站核验。

来源信息

继续浏览同类 Skills