Skip to content
Browse documentation

Test and debug your game

Check game logic, run browser tests, diagnose blank canvases, and reproduce production-only failures.

View Markdown
On this page

Start with the available checks

Every generated kit
pnpm lint
pnpm build
pnpm preview

Read package.json before running optional scripts. The Vitest add-on provides test; the Playwright add-on provides e2e and e2e:ui. Both use Chromium. New kits prepare the matching browser automatically when you run tests locally; later runs reuse the download.

When the test add-ons are installed
pnpm test
pnpm e2e

Use Updating an existing game to add missing test tools safely. A missing script is a configuration issue, not a failing game test.

Prepare the test environment

With either test add-on selected, pnpm run setup prepares local HTTPS and Chromium together. Your operating system may ask you to trust a local development certificate. This does not create a cloud project or register a public domain. To prepare only the browser, run pnpm test:setup. Dependency installation itself does not download browsers or change certificate trust.

Optional setup before the first test
pnpm run setup
Interactive Playwright tests
pnpm e2e:ui
pnpm e2e --grep keyboard

These commands require the Playwright add-on. The test server starts automatically at http://127.0.0.1:4173; you do not need domain setup or a running pnpm dev. Set SPAWN_E2E_HTTPS=1 to test a named HTTPS origin after local domain setup; CI always uses loopback. Change e2e/game.spec.ts to test your game's behavior.

Linux CI runner; both test add-ons selected
pnpm install --frozen-lockfile
pnpm test:setup --with-deps
pnpm test
pnpm e2e

Commit your lockfile before using this CI example. CI skips automatic browser downloads and uses a loopback test server. On supported Linux runners, --with-deps installs system libraries and may require administrator access. For an already prepared offline machine, set SPAWN_SKIP_BROWSER_INSTALL=1. If a download fails, tests stop: check network/proxy access and retry pnpm test:setup.

Test a game rule

The generated src/score.ts exports advanceScore. Its test belongs in src/score.test.ts. Test behavior players depend on, including boundary values, rather than copying the function's implementation.

src/score.test.ts; requires the Vitest add-on
import { expect, it } from "vitest"
import { advanceScore } from "./score"

it("awards the first collectible", () => {
  expect(advanceScore(0)).toBe(1)
})

it("preserves the accumulated score", () => {
  expect(advanceScore(41)).toBe(42)
})

Run pnpm test. Both assertions should pass with the generated score function. If you change the scoring rules, update the expected behavior deliberately. Keep coverage checks enabled and add cases for new branches.

Verify behavior in a real browser

Use the generated Playwright configuration and existing test location as your starting point. It supplies the application's test origin and server. Canvas presence is a useful smoke check, but it does not prove the player moved or the game rules worked.

e2e/smoke.spec.ts; requires the Playwright add-on
import { expect, test } from "@playwright/test"

test("opens the game without an uncaught error", async ({ page }) => {
  const errors: string[] = []
  page.on("pageerror", error => errors.push(error.message))
  await page.goto("/")
  await expect(page.locator("canvas")).toBeVisible()
  await page.keyboard.press("ArrowRight")
  expect(errors).toEqual([])
})

Save the example as e2e/smoke.spec.ts and run pnpm e2e. Extend it with observable outcomes specific to your game: a score label changes, a restart button resets the scene, or a level-complete screen appears. Test touch controls on a phone-sized viewport when you advertise mobile support. Check audio after a user gesture.

Diagnose the first failure

To find a browser error, open your browser's developer tools from its menu, choose Console, and reload the game. Start with the first red error. In Network, reload again and look for failed file requests; their URLs can reveal a wrong asset path. Share the error text with your agent, without credentials.

SymptomCheck next
Blank canvasRead the first console error. Confirm the renderer initializes, the canvas has a size, and required assets load.
Missing artwork or soundInspect the failed network URL, filename case, and whether the file exists in dist. A public/ prefix is not part of the browser URL.
Local HTTPS does not openRun pnpm exec dev-domains doctor and pnpm exec dev-domains urls. Follow certificate setup; check the printed origin.
Browser executable missingRetry pnpm test:setup. Check network/proxy access if the download fails.
Works in development onlyRebuild and use pnpm preview. Check browser-visible environment variables and production asset paths.
Hosted source install failsCommit an up-to-date pnpm lockfile. Check for private registries, Git dependencies, or required install scripts.
Old behavior after deploymentConfirm the project, active release, and URL; inspect cache/service-worker behavior in the browser.

Fix the earliest actionable error, then rerun the same steps. Avoid changing multiple unrelated systems before you can reproduce the failure.

Make a useful failure report

Open Dashboard → Deployments → release → Build logs for the working browser path. Use CLI installation to run the deployment commands below. Record the exact steps, expected result, actual result, browser/device, and whether it happens in development, preview, or the hosted release. Include the first console error and relevant failed request. For hosted builds, include the project and deployment IDs plus the failing log excerpt. Remove tokens and credentials before sharing.

Retrieve deployment diagnostics
pnpm dlx @spawnkit/cli status DEPLOYMENT_ID --project YOUR_PROJECT_ID
pnpm dlx @spawnkit/cli logs DEPLOYMENT_ID --project YOUR_PROJECT_ID

Need a hand? Get support

Explore the guides

Build your first game

Download a standalone game kit, run it locally, and make your first change.

Create and build a game with @spawnkit/cli

Start in a parent folder, generate your game, then run every development command inside the new game folder.

Upload an existing browser game

Upload a self-contained browser build. Your original source, engine, and build tools can stay as they are.

Publish your game

The dashboard accepts a ZIP of your built game. You will need an account to deploy it.

Use the SpawnKit dashboard

The dashboard manages your hosted games. Your editor or AI agent remains where you change and build your game source.

Make a browser game with Codex

Use Codex with a standalone TypeScript game kit. Start with a working scene and improve it one playable change at a time.

Make a browser game with Claude Code

Use Claude Code with a standalone TypeScript game kit. Start with a working scene and improve it one playable change at a time.

Make a browser game with Cursor

Use Cursor with a standalone TypeScript game kit. Start with a working scene and improve it one playable change at a time.

Extend your game

Find the right files, make a focused change, and check it in a playable build.

A complete publishing example

Follow a small example from editable source to a ZIP with index.html at its root. Use your own game title, description, and artwork.

Add tools to an existing game

Keep a recoverable baseline, inspect the proposed changes, and verify one addition at a time.

Test and debug your game

Combine automated checks with a short playthrough of the production build. A successful build alone does not verify gameplay.

Project structure and configuration

Your downloaded kit is a standalone TypeScript project. Its files belong to you and do not depend on the SpawnKit repository.

SpawnKit CLI reference

A command-by-command reference to the implemented CLI. Local generation works without an account; hosted operations require access to a project.

Accounts and access

Building locally is account-free. Publishing requires an account with access to the target project.

Agents and API resources

Public discovery endpoints are account-free. Use the dashboard or @spawnkit/cli for publishing.

16 guides available