The long tail of app-debugging - load that skill first for the core loop (page inspect → console/resources → logs fn → fn call → page screenshot). This reference is for when reading the page isn't enough and you have to drive it: verify state across a reload, feed the app a real file or a real camera frame, advance a simulation's clock, or prove two multiplayer clients see each other.
Almost everything here is a flag or a pattern on gipity page eval <url> <expr> (the multiplayer sections use gipity page test) - see app-debugging for the base command, its flag table, and the expression rules (an expression or a statement body, whose trailing expression is returned; return the value, don't post-process the output).
--step - many checks, one page load
Each separate gipity page command is a fresh page load. Every page eval / page inspect invocation opens the URL anew, so anything you set up in one command (a window.onerror trap, a global you assigned) is gone by the next - you can't "install a probe, then read it" across two commands.
--step runs more expressions against the SAME loaded page - each one after the last, sharing everything the page already paid for (a vision model, a booted game, a connected socket) and everything the previous step left behind. So a several-part check ("it detects my throw" → "it scores the round" → "the tally survives the next round") is one page load, not one per assertion. --json returns { result, stepResults: [...] }:
gipity page eval <url> "document.querySelector('#play').click(), 'started'" \
--step "(async()=>{ await new Promise(r=>setTimeout(r,1000)); return document.querySelector('#score').textContent; })()"
--reload - does the state survive a refresh?
--reload gives you a two-phase check across a reload: the expressions run, the page reloads in place (localStorage/sessionStorage/cookies preserved), then the --reload expression runs against the post-reload DOM. That is the direct test for "remember it if I close the tab and come back" - seed state, reload, assert the restored UI - no same-origin-iframe harness needed:
# Phase 1 saves state through the app's own UI; phase 2 proves it survives a reload:
gipity page eval "<url>" \
"(()=>{ document.querySelector('#label').value='Trip'; document.querySelector('#save').click(); return localStorage.getItem('countdown'); })()" \
--reload "({ restored: !!localStorage.getItem('countdown'), heading: document.querySelector('#display')?.textContent })"
--reload-file <path> reads the reload expression from a file.
Feeding the page real bytes and long scripts
Verifying against a real file (MP3, image, PDF, a multi-KB data blob)? Use --fixture, don't inline the bytes. The eval body is capped at 64 KB (it's delivered as one shell argument to the sandbox), and the eval runs in the page - so bulk/binary data can't be pasted into the expression. --fixture <path> hosts a local file as a public asset, hands your eval a fetch-able fixtureUrl, runs the eval, and deletes the hosted copy afterwards - no manual upload/deploy/cleanup dance. The page fetches it in-page and drives the app's own code over the real bytes:
# Real binary in, parsed result out. fixtureUrl is injected into the eval scope:
gipity page eval <url> --fixture ./sample.mp3 \
"(async()=>{ const buf = await fetch(fixtureUrl).then(r=>r.arrayBuffer()); const tags = await window.MyApp.parseId3(buf); return { title: tags.title, hasCover: !!tags.cover }; })()"
Pass --fixture more than once for several files; each is exposed under fixtures['<basename>'] (and the first as fixtureUrl). Any size, binary-safe - the bytes travel over HTTP, never through the eval body.
Large or multi-line eval body? Put it in a file with --file <path>, don't inline it. A long or multi-line expression pasted as a shell argument is where quoting breaks - a stray quote/paren/newline and the shell hands page eval a mangled (or empty) <expr>, so the CLI sees a missing argument and prints the usage help instead of running anything. --file ./probe.js reads the body from disk verbatim (no shell quoting in play) and runs it exactly as if it were the inline <expr>:
gipity page eval <url> --file ./probe.js
App-relative import() works. A dynamic import('./packages/i18n/index.js') inside the eval resolves against the page URL, so you can load and drive the app's own ES modules without hand-building the deployed /account/project/ path. Literal ./, ../ and (on *.gipity.ai) root-absolute /... specifiers are resolved against the app; full URLs and bare specifiers pass through unchanged.
The eval runs against the live page with a ~30s in-page execution budget (45s with --camera; --timeout raises it to 90s). A single expression that awaits several slow things (network, animation timers, polling a selector in a loop) can blow that budget; you'll get a timeout message telling you to split it. Prefer one focused expression per fact, or use --wait-for <selector> to gate on readiness instead of await-ing inside the body.
Every limit is a hard limit, so you can predict how long a call takes: page load (at most ~20s) + --wait or --wait-for (its --wait-timeout) + --timeout for each script (<expr> and each --step), plus a few seconds to start and close the browser. The script's result comes back the moment it returns, even on a page that keeps the CPU busy afterwards. When a call could run past ~100s, page eval says so before it waits. Any call over 10s prints where the time went, and --json always carries it as timing:
timing: 16.6s = hosting files 0.8s + camera/feed setup 1.2s + browser start 1.6s + page load 0.6s + wait/wait-for 7.6s + script 2.3s + step 1 0.9s + cleanup 1.2s
Read it before changing anything: a big wait/wait-for is the app starting up (a vision model loading), a big script is your own body, and a big sandbox queue is a busy platform. (empty result) always means the script really returned nothing; a script that never got to run is reported as an error saying so.
Catching an error the console didn't show you
Each gipity page call loads the page fresh, so an error thrown earlier is gone by the next call. To catch a boot-time or runtime error, the page itself has to record it, then you read it in a single eval. Add a tiny logger to the app's own boot (it ships with the app, so it's present on every load):
// in the app's entry, before anything that might throw:
window.__errs = [];
addEventListener('error', (e) => window.__errs.push(e.error?.stack || e.message));
addEventListener('unhandledrejection', (e) => window.__errs.push('REJECTION: ' + (e.reason?.stack || e.reason)));
# then one eval reads what threw during this load:
gipity page eval "<url>" "JSON.stringify(window.__errs)" --wait 4000
For errors that only surface after async work or a state change, give them time with --wait, or gate on --wait-for "<selector that appears once settled>". (page inspect's Console already captures uncaught errors for the load it snapshots - reach for the in-app logger when you need errors from a specific later moment, or a value the console doesn't show.)
A message-less error: (...) line in Console is a cross-origin "Script error" from a third-party <script> (e.g. a CDN) loaded without crossorigin="anonymous" - not your own logic (the Gipity SDK sets it, so its errors show real messages; the window.__errs trap can't see cross-origin ones). Add crossorigin="anonymous" to that <script> (the CDN must also send Access-Control-Allow-Origin) to read the real message.
Camera apps: point the headless browser at a picture
The camera is not one of the things the headless browser can't do (see "What the headless browser can't test" in app-debugging) - --camera <image> gives page eval / page screenshot a synthetic webcam that plays your image on a loop (and a synthetic mic, so getUserMedia never prompts or fails). The app's real getUserMedia → inference → onResult → UI pipeline runs against it, so you read the app's own output instead of a hand-fed fake:
# The picture IS the camera. Read whatever the app renders from it.
gipity page eval <url> --camera ./palm.png --wait 6000 \
"(()=>{ document.querySelector('#start').click(); return new Promise(r => setTimeout(() => r(document.querySelector('#throw').textContent), 4000)); })()"
gipity page screenshot <url> --camera ./palm.png --wait 6000 # see the overlay + label it drew
Any local PNG/JPEG/WebP still works (or an MP4/WebM/Y4M/MJPEG video); GIFs and URLs are rejected. What is in the picture decides the result: an empty read on a looped still is the picture or the app's wiring, never the wait. For a hand/gesture app the picture must show a person with a hand raised beside the shoulder (a close-up of a hand reads as no hand); the kit skills (web-vision-mediapipe, web-vision-detect) give a gipity generate image prompt that works and a one-command check that needs no click. The model downloads and compiles on the first frame, so the script gets a roomier in-page budget on --camera runs (raise it with --timeout <ms> if a big model needs longer). That load is the expensive part - check everything about the app in ONE camera run, using --step (above) rather than a fresh --camera eval per assertion; the model stays warm across steps. Don't rebuild the app to expose test hooks on window: a debug surface compiled into the app the user opens is not verification, and it isn't needed.
Time-dependent logic: step the app's own clock
Never wait on real time - step the simulation. The headless browser has no GPU, so a WebGL scene software-renders at ~2-3 fps. Game engines cap their per-frame delta for stability (the 3D templates cap at 1/30s), which means simulated time advances only as fast as frames paint - roughly a twelfth of wall time. Sleep 3 real seconds expecting a 3-second charge and the player creeps about one unit - the assertion fails as a false negative, not an app bug. It bites physics, animation, canvas, and 2d-game timers alike.
When the page paints too slowly to trust a wall-clock wait, page eval says so:
⚠ Slow render: page painted at 2.6 fps. Waiting on real time (setTimeout) advances animation/physics time far slower than it looks ...
The fix is to advance the simulation yourself, without rendering - deterministic and ~350× faster. The 3D templates export advance(seconds) for exactly this; it runs the same physics/player/game/feature chain a real frame runs, just without the paint:
# Does a dropped block actually fall and settle?
gipity page eval <url> "const core = await import('./js/core.js');
await core.whenReady(); // real boot, no guessed sleep
const b = core.primitives.createPart({ position:{x:0,y:20,z:0} });
core.advance(4); // 4s of WORLD time, ~150ms real, deterministic
return JSON.stringify({ dropped: +(20 - b._body.translation().y).toFixed(1), asleep: b._body.isSleeping() });"
# → {"dropped":20.4,"asleep":true}
Because advance() runs a fixed step, the same seconds gives a bit-identical result every run, on any machine - assert exact values, not tolerances. Advance in whole seconds until the bodies you care about report isSleeping(), rather than picking a duration and hoping.
Sending input to a frame-looped game
A game reads input in two stages: an event listener sets a flag (inputState.mouseDown = true), and the next frame's update consumes it. A synthetic event that is pressed and released in the same tick is never seen by a frame, and one of the wrong type is never seen at all. Three rules:
- Dispatch the exact event type the game listens for. A scripted
PointerEvent('pointerdown')does not produce themousedown/clicka real pointer would (only trusted input does), and vice versa. Read the listener (grep -n addEventListener src/js) and send that type, on that target. The 3D templates listen formousedownon the canvas,mouseupondocument, andkeydown/keyuponwindow, keyed one.code. - Press, step, release. Step the loop between the down and the up so a frame runs while the input is held.
- Assert on game state, not pixels. Return the part count, a position, a score.
gipity page eval <url> --file - <<'EOF'
const core = await import('./js/core.js');
await core.whenReady();
const canvas = document.querySelector('canvas');
const input = core.player.inputState;
canvas.dispatchEvent(new MouseEvent('mousedown', { button: 0, bubbles: true, clientX: 640, clientY: 360 }));
const held = input.mouseDown; // did the listener fire?
core.advance(0.1); // frames run while the button is held
document.dispatchEvent(new MouseEvent('mouseup', { button: 0, bubbles: true }));
window.dispatchEvent(new KeyboardEvent('keydown', { code: 'KeyW', bubbles: true }));
const forward = input.forward;
core.advance(1); // walk forward for 1s of world time
window.dispatchEvent(new KeyboardEvent('keyup', { code: 'KeyW', bubbles: true }));
({ held, forward, parts: core.workspace.parts.size }) // plus whatever your game changed
EOF
If the game ignores the input, check the flag first (held above): false means the event type or target is wrong, true means the frame logic is where to look. Pointer lock, and anything else gated on a trusted gesture, can't be granted to a script: test the logic behind it directly.
For an app without such a hook, expose one: keep the step function pure (function tick(dt)), call it from your requestAnimationFrame loop, and put it on window so an eval can drive it directly. Don't setTimeout and hope.
Multiplayer apps: verifying presence/shared state across clients
Presence and shared state only mean anything when two clients are live at the same time. Two important traps:
gipity page testwithout--observedoes passive page loads only - it never submits a name, clicks, or reads shared state, so it can't tell you whether clients see each other.- Two separate
gipity page evalcalls run sequentially - each finishes before the next starts, so the clients never coexist and each sees only itself. That looks identical to a broken presence kit, but it's a false negative from the harness, not a bug in your app. Don't go debugging the transport over it.
The fix for both is the interactive mode of page test, which spins up N genuinely concurrent clients, drives an action in each, samples the shared state over a window, and then verifies the clients actually overlapped in time (refusing to call a non-overlapping run a pass):
gipity page test ".../app/" --clients 2 --labels Alice,Bob --action "document.querySelector('#name').value='{{label}}'; document.querySelector('form').requestSubmit();" --observe "document.querySelectorAll('.present').length"
{{label}} / {{i}} are substituted per client. Each client runs --action once, then samples --observe across --hold ms (default 8000, --samples readings). A working presence app prints each client's count rising as the other joins (e.g. 1 → 1 → 2 → 2) plus ✓ all clients overlapped for ~Ns. If the clients didn't overlap (too much --stagger, or more --clients than free browser slots), it says so loudly and exits non-zero instead of giving you a misleading green. Use --wait-for <selector> to gate the action on the form being ready.
Multiplayer apps: URL-param test mode (also handy for multiplayer lobbies)
A click-driven multi-client test (two browsers, host on one, join from the other) is real work to write and slow to run. A small URL-param test mode in the app turns it into two passive page loads:
?test-name=Alice- auto-fills the player name on load.?test-action=host- once on the lobby, auto-clicks Host (or your equivalent).?test-action=join- once on the lobby, auto-joins the first open game.?test-action=join&room=<id>- joins a specific room.
With those, verification is a single gipity page test run - it loads the URL in N staggered headless clients (client 0 settles first as host, the rest join) and flags any error/crash lines across their consoles:
gipity page test ".../app/?test-name=Player&test-action=join" --clients 3 --stagger 8 --wait 10000
For asymmetric roles (one host, others join), don't run two separate calls - they execute sequentially, so the host client is gone (or its room is stale) by the time the joiners load, and you get a false negative. Co-launch the roles in one interactive invocation instead: with --observe, {{label}} / {{i}} substitute into the URL too, and the overlap check confirms the roles actually coexisted:
gipity page test ".../app/?test-name={{label}}&test-action={{label}}" --clients 2 --labels host,join --observe "document.querySelector('[data-screen]')?.dataset.screen"
Client 0 loads ?test-action=host and client 1 ?test-action=join, genuinely concurrently - no backgrounding + sleep dance, no stale lingering room to land in.
No Puppeteer, no Chromium libs, no DOM driving - a passive page test (no --observe) just loads the URL, so the URL-param test mode is what makes the load alone exercise the join path. (When you'd rather drive the form than add a test mode, the interactive page test --observe above does the DOM driving for you.) Implement it once per multiplayer app and every realtime change is a 30-second smoke test from there on. Pair it with the data-testid / data-screen / data-ready conventions from web-app-basics for any leftover click-driven tests.
Related skills
- app-debugging - the core loop this reference extends
- app-testing - testing functions server-side (
ctx.fn.call/callAs, the isolated test DB) - web-vision-mediapipe / web-vision-detect - the camera apps
--cameraverifies - 3d-engine - the
advance(seconds)hook the 3D templates export - app-realtime - the multiplayer rooms the two-client checks verify