| name | phaser-automation-kit |
| description | Quick reference for Phaser game automation with agent-browser. Skip DOM snapshots and use window.__TEST__ directly. Use when automating Phaser 3 games, testing canvas/WebGL applications, or working with game state inspection. Trigger: "phaser automation", "test phaser", "game automation", "window.__TEST__", "skip snapshot". |
Phaser Automation Kit
Quick reference for automating Phaser games with agent-browser. Skip snapshot -i and use window.__TEST__ directly.
Core Principle
For Phaser games, skip DOM snapshots. The test seam (window.__TEST__) provides all necessary access without DOM inspection.
Quick Start
agent-browser open http://localhost:3000?test=1&seed=42
agent-browser eval "new Promise(r => { const c = () => window.__TEST__?.ready ? r(true) : setTimeout(c, 100); c(); })"
agent-browser eval "window.__TEST__.commands.goToScene('GameScene')"
agent-browser eval "window.__TEST__.gameState()"
Common Patterns
Scene Navigation
agent-browser eval "window.__TEST__.commands.goToScene('GameScene', { level: 1 })"
agent-browser eval "window.__TEST__.sceneKey"
State Inspection
agent-browser eval "window.__TEST__.gameState()"
agent-browser eval "window.__TEST__.gameState().score"
agent-browser eval "window.__TEST__.gameState().player.x"
Functional Triggers
agent-browser eval "window.__TEST__.commands.clickStartGame()"
agent-browser eval "window.__TEST__.commands.collectCoin(100, 200)"
agent-browser eval "window.__TEST__.commands.reset()"
Input Simulation
agent-browser press ArrowRight
agent-browser press Space
agent-browser press KeyW
agent-browser click 400 300
Waiting for State Changes
agent-browser eval "window.__TEST__.ready"
agent-browser eval "new Promise(r => { const c = () => window.__TEST__.gameState().score > 0 ? r(true) : setTimeout(c, 100); c(); })"
Standardized Test Seam Structure
All Phaser games should expose:
window.__TEST__ = {
sceneKey: null,
ready: false,
seed: null,
gameState: () => ({
scene: window.__TEST__.sceneKey,
score: gameState.score,
}),
commands: {
goToScene: (key, data) => {},
clickStartGame: () => {},
collectCoin: (x, y) => {},
reset: () => {},
}
};
Workflow Comparison
❌ Wrong: Using DOM Snapshots
agent-browser open http://localhost:3000
agent-browser snapshot -i
agent-browser click @e1
✅ Correct: Using Test Seam
agent-browser open http://localhost:3000?test=1&seed=42
agent-browser eval "window.__TEST__.ready"
agent-browser eval "window.__TEST__.commands.goToScene('GameScene')"
agent-browser eval "window.__TEST__.gameState()"
When to Use DOM Snapshots
Only use snapshot -i for:
- DOM-based UI: HTML menus, buttons, forms
- Hybrid games: DOM menus + canvas gameplay (use snapshot for menus only)
For pure Phaser/canvas games, always use window.__TEST__.
Direct Scene Access
Test specific scenes without full game flow:
agent-browser open http://localhost:3000?scene=GameScene&test=1&seed=42
agent-browser eval "window.__TEST__.commands.goToScene('GameScene', { level: 3 })"
Error Checking
agent-browser errors
agent-browser eval "typeof window.__TEST__ !== 'undefined'"
agent-browser eval "window.__TEST__.ready"
Screenshot Testing
After deterministic setup:
agent-browser set viewport 1280 720
agent-browser eval "window.__TEST__.ready && window.__TEST__.frameCount >= 10"
agent-browser screenshot gameplay-state.png
Integration with TestManager
If using TestManager pattern (see @phaser-game-testing):
agent-browser eval "window.__TEST__.gameState()"
agent-browser eval "window.__TEST__.commands.goToScene('GameScene')"
Related Skills
@phaser-game-testing: Complete testing guide, TestManager pattern, unit testing
@vite-agent: Vite configuration for agent automation
Remember
- Skip
snapshot -i for Phaser games
- Use
window.__TEST__ directly
- Use commands for functional triggers
- Check state via
gameState()
- Wait for ready before interactions