Skip to content

DriveContext

Defined in: tools/lab/src/grammar/drive.ts:76

C extends ControlSchema = ControlSchema

controls: ControlValues<C>

Defined in: tools/lab/src/grammar/drive.ts:80

What the controls were set to when the run started.


events: object

Defined in: tools/lab/src/grammar/drive.ts:114

The engine’s event log. The run is the only thing issuing frames, so waitFor has to be started before the frames that satisfy it and awaited after — awaiting it first parks the run with nothing left to advance it:

const hit = events.waitFor("enemy:hit", { withinFrames: 60 });
await step(60);
await hit;

clearLog: () => void

void

getLog: () => EventLogEntry[]

EventLogEntry[]

isEnabled: () => boolean

boolean

setCapacity: (n) => void

number

void

setEnabled: (enabled) => void

Turn event-log recording on/off at runtime. Off means zero per-event allocation: the EventBus tap detaches and recordBusEvent is never called. DebugConfig.eventLog controls the startup default; this is the runtime switch for toggling mid-session.

boolean

void

waitFor: (pattern, options?) => Promise<EventLogEntry>

Resolve the earliest retained match without consuming it, or wait for a future match. Clear the log before an action to require a new event. withinFrames expires after that many completed engine frames; events on the deadline frame match first. Zero searches retained history only. Disposing the Inspector or disabling the log rejects pending waits.

string | RegExp

"scene" | "entity" | "bus"

number

Promise<EventLogEntry>


expect: ExpectStatic

Defined in: tools/lab/src/grammar/drive.ts:123

Jest-style assertions: expect(hp).toBeLessThan(before).


readonly framesUsed: number

Defined in: tools/lab/src/grammar/drive.ts:82

Frames this run has spent so far, counting frames issued any way.


input: DriveInput

Defined in: tools/lab/src/grammar/drive.ts:83


pointer: object

Defined in: tools/lab/src/grammar/drive.ts:102

Clicks that reach @yagejs/ui primitives — a build menu, a pause screen, a confirm dialog. input writes engine input state and never reaches one; these dispatch real pointer events at the canvas, so the renderer hit-tests and delivers them.

A button’s onClick has already run when the call returns. Engine input state reflects the press one frame later, so await step(1) before asserting on an action.

One primary mouse pointer only. A touch pointer or a second finger stays with input, which writes engine state and reaches no button.

const hit = pointer.click(buttonId);
expect(hit.path.some((node) => node.type === "UIButton")).toBe(true);

click: (target, opts?) => InspectorPointerHit

Presses and releases at one point, which is what a UIButton requires to run its onClick.

InspectorPointerTarget

InspectorPointerButtonOpts

InspectorPointerHit

down: (target, opts?) => InspectorPointerHit

Presses a mouse button, left unless opts says otherwise.

InspectorPointerTarget

InspectorPointerButtonOpts

InspectorPointerHit

hitTest: (target) => InspectorPointerHit

Resolves target and reports what is under it, dispatching nothing.

InspectorPointerTarget

InspectorPointerHit

move: (target) => InspectorPointerHit

Moves the pointer, which drives hover state. Takes no button: a move presses and releases nothing, and carries whichever buttons an earlier down left held.

InspectorPointerTarget

InspectorPointerHit

up: (target, opts?) => InspectorPointerHit

Releases a mouse button, left unless opts says otherwise.

InspectorPointerTarget

InspectorPointerButtonOpts

InspectorPointerHit


scene: Scene

Defined in: tools/lab/src/grammar/drive.ts:78

The scene the run drives. findByKey reaches what the scenario spawned.

capture(label?): Promise<string>

Defined in: tools/lab/src/grammar/drive.ts:128

Screenshots the canvas into the run’s result and resolves with the same PNG data URL.

string

Promise<string>


step(frames?, opts?): Promise<void>

Defined in: tools/lab/src/grammar/drive.ts:116

Advances frames frames, one at a time.

number

DriveStepOptions

Promise<void>


until(predicate, opts?): Promise<number>

Defined in: tools/lab/src/grammar/drive.ts:121

Advances a frame at a time until predicate holds, and resolves with the number it took. Rejects after maxFrames (600 by default).

() => boolean

DriveUntilOptions

Promise<number>

Coding agents: fetch https://yage.dev/llms.txt first and prefer the Markdown references it links over these HTML pages. This page's Markdown counterpart is /llms/tools/lab.md.