Skip to main content

phaser-component-test-scenes

Standalone test scenes for Phaser UI components. Use when building or testing a Phaser UI component (slider, toggle, HUD, button, modal, volume control). Create one scene per component, boot via ?scene=ComponentNameTestScene, and test in isolation instead of on the full game page. Unit-test methodology for Phaser components.

Informações da origem

Repositório
pmarashian/cursor-agent-skills
Última atividade na origem
13 de fevereiro de 2026 às 19:51
Idioma detectado do SKILL.md
inglês
Estrelas
2
Forks
1

Opções de instalação

Por padrão, está selecionado o prompt que primeiro revisa a origem. Você pode mudar para um comando direto ou baixar uma cópia local.

Revise os arquivos de origem

Leia o SKILL.md e os arquivos complementares exibidos pelo SkillsMP antes de decidir se vai instalar.

Explorador de arquivos
3 arquivos

Exibindo SKILL.md

SKILL.md
Instruções da origem · Visualização somente leitura
name
phaser-component-test-scenes
description
Standalone test scenes for Phaser UI components. Use when building or testing a Phaser UI component (slider, toggle, HUD, button, modal, volume control). Create one scene per component, boot via ?scene=ComponentNameTestScene, and test in isolation instead of on the full game page. Unit-test methodology for Phaser components.
# Phaser Component Test Scenes ## Overview Test Phaser UI components in isolation by giving each component its own **component test scene**. Boot with `?scene=<TestSceneKey>` and verify behavior via the test seam—no full game or navigation required. ## When to Use - Building or testing a Phaser UI component: slider, toggle, HUD element, button, modal, volume control, control-scheme selector, etc. - Verifying layout, interaction, or test seam for a single component without loading the full scene where it is used. ## Rule Do not rely on testing the component only inside the full scene where it is used. Create a **component test scene** for that component and test there first. ## Workflow 1. **Implement or extract the component** (reusable class or clearly bounded logic). 2. **Add a dedicated scene** that only instantiates this component (and minimal deps: assets, mock callbacks). 3. **Register the scene in main.ts** so it can be booted via `?scene=<TestSceneKey>`. 4. **Expose a test seam** on the test scene: `window.__TEST__.commands` for that component only (e.g. `setSliderValue`, `getSliderValue`, `clickToggle`, `getToggleState`). 5. **Run verification** by opening `http://localhost:<port>?scene=<TestSceneKey>` and using the test seam (and optional screenshots), not by navigating through the full game. ## Naming and Layout - **Scene key**: `SliderTestScene`, `ToggleTestScene`, `HUDTimerTestScene`, etc. (suffix `TestScene`). - **Path**: `src/scenes/component-tests/<ComponentName>TestScene.ts` (or `src/scenes/test-scenes/` if the repo prefers). ## Test Scene Structure - **preload()**: Only assets needed for this component. - **create()**: Create the component under test (centered or at fixed position), then call `setupTestSeam()` with commands that drive/query only this component. - No game logic, no navigation to other scenes (optional "Back" or link to main menu for manual use is fine). ## Test Seam Shape Use the same structure as other Phaser scenes: `window.__TEST__.sceneKey`, `window.__TEST__.commands`, and a `gameState()` (or equivalent) that returns component state. See **phaser-test-seam-patterns** for test seam shape and **phaser-scene-template** for the base scene/test-seam checklist. Component test scenes are a *variant*: single component + minimal harness. ## Template See `assets/component-test-scene-template.ts` for a minimal Phaser scene with a placeholder component and example test seam commands. ## Resources - `assets/component-test-scene-template.ts` - Template for new component test scenes - `references/why-component-test-scenes.md` - Rationale for isolation and faster feedback - **phaser-test-seam-patterns** - Test seam discovery and commands - **phaser-scene-template** - Base scene lifecycle and test seam checklist
Ver no GitHub