mirror of
https://github.com/PlayableIntelligence/game-creator.git
synced 2026-09-19 07:34:10 +08:00
c262955248
The iterate-client.js and verify-runtime.mjs scripts were defined outside templates and never used in the make-game pipeline. This moves them into both templates as the single source of truth, fixes the `playwright` → `@playwright/test` import mismatch, adds robust Playwright prerequisite checking, and inserts Phase 2.5 (iterate check) into the verification protocol so every pipeline step gets screenshots + game state feedback. Also adds render_game_to_text(), advanceTime(), and iterate client docs to templates, game-qa skill, and CLAUDE.md. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
57 lines
1.7 KiB
JavaScript
57 lines
1.7 KiB
JavaScript
#!/usr/bin/env node
|
|
// =============================================================================
|
|
// verify-runtime.mjs — Headless runtime verification for browser games
|
|
//
|
|
// Launches headless Chromium, loads the game, checks for runtime errors
|
|
// (WebGL failures, uncaught exceptions, console errors).
|
|
// Exit 0 = pass, Exit 1 = fail (prints errors to stderr).
|
|
//
|
|
// Usage:
|
|
// node scripts/verify-runtime.mjs
|
|
// PORT=5173 node scripts/verify-runtime.mjs
|
|
// =============================================================================
|
|
|
|
import { chromium } from '@playwright/test';
|
|
|
|
const PORT = process.env.PORT || 3000;
|
|
const URL = `http://localhost:${PORT}`;
|
|
const WAIT_MS = 3000;
|
|
|
|
async function verify() {
|
|
const errors = [];
|
|
const browser = await chromium.launch({ headless: true });
|
|
const page = await browser.newPage();
|
|
|
|
page.on('pageerror', (err) => errors.push(`PAGE ERROR: ${err.message}`));
|
|
page.on('console', (msg) => {
|
|
if (msg.type() === 'error') {
|
|
errors.push(`CONSOLE ERROR: ${msg.text()}`);
|
|
}
|
|
});
|
|
|
|
try {
|
|
const response = await page.goto(URL, { waitUntil: 'domcontentloaded', timeout: 10000 });
|
|
if (!response || response.status() >= 400) {
|
|
errors.push(`HTTP ${response?.status() || 'NO_RESPONSE'} loading ${URL}`);
|
|
}
|
|
} catch (e) {
|
|
errors.push(`NAVIGATION ERROR: ${e.message}`);
|
|
}
|
|
|
|
// Wait for game to initialize and render
|
|
await page.waitForTimeout(WAIT_MS);
|
|
|
|
await browser.close();
|
|
|
|
if (errors.length > 0) {
|
|
console.error(`Runtime verification FAILED with ${errors.length} error(s):\n`);
|
|
errors.forEach((e, i) => console.error(` ${i + 1}. ${e}`));
|
|
process.exit(1);
|
|
}
|
|
|
|
console.log('Runtime verification PASSED — no errors detected.');
|
|
process.exit(0);
|
|
}
|
|
|
|
verify();
|