Prompt file imported from CrosswiredStudios/MarioKartClone-Qwen3.8Experiment (
.github/prompts/debug-e2e.prompt.md). Fill in{{arguments}}before use. Copyright stays with the author.
Diagnose a failing or flaky Playwright e2e test. Target: {{arguments}}
Work through this decision tree in order. Stop at the first confirmed cause and report it.
- Stale
dist/? —vite previewserves the lastdist/build, NOT live source. If the failure is "a just-added handle/property is missing at runtime" while unit tests pass, the bundle is stale. Fix:npm run build, then re-run. - Stale
:4173listener? — a leftover preview server is silently reused (reuseExistingServer: !CI), so e2e tests old code. Kill it:Get-NetTCPConnection -LocalPort 4173 -State Listen | % { Stop-Process -Id $_.OwningProcess -Force }then re-run. - Throttling / wall-time? — the integrated-browser tab is rAF-throttled when backgrounded (countdown stuck, no state change). Playwright headless Chromium is NOT throttled — make sure the test runs under
npx playwright test, not the integrated browser. Also check the timeout: a full 3-lap race takes ~30–90 s wall time; usetest.setTimeout(ms)(thetest(title, body, timeoutMs)overload was removed in Playwright v1.62 and is silently ignored). - Console errors? — capture
page.on("console")andpage.on("pageerror")output. A runtimeReferenceError/TypeError(e.g. a renamed Babylon API) usually shows up here even when the build and tsc pass. - DOM assertion / detached element? — menu and defeat-panel buttons are rebuilt every frame, so Playwright
.click()times out with "element was detached from the DOM". Click via direct DOM dispatch in onepage.evaluate:[...document.querySelectorAll('.menu-item')].find(e => e.textContent.trim() === 'LABEL').click()Also: assert transient overlays are REMOVED (toHaveCount(0)), not just that state changed.
Verification rules:
- Verify via
page.evaluate(window.__game…)/window.__sw.dbg(fn)and DOM snapshots — NEVER screenshots (they fail in this environment with a 400). - Dev-only handles are gated behind
?debug— make sure the spec navigates to/?debugif it needs them. - For physics-related failures, test against
vite preview, notvitedev (dev serves HTML for the Havok.wasm).
Report the confirmed root cause, the evidence, and the fix (or the next diagnostic step if the cause is not yet confirmed).