DriveContext
Defined in: tools/lab/src/grammar/drive.ts:76
Type Parameters
Section titled “Type Parameters”C extends ControlSchema = ControlSchema
Properties
Section titled “Properties”controls
Section titled “controls”controls:
ControlValues<C>
Defined in: tools/lab/src/grammar/drive.ts:80
What the controls were set to when the run started.
events
Section titled “events”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
Section titled “clearLog”clearLog: () =>
void
Returns
Section titled “Returns”void
getLog
Section titled “getLog”getLog: () =>
EventLogEntry[]
Returns
Section titled “Returns”EventLogEntry[]
isEnabled
Section titled “isEnabled”isEnabled: () =>
boolean
Returns
Section titled “Returns”boolean
setCapacity
Section titled “setCapacity”setCapacity: (
n) =>void
Parameters
Section titled “Parameters”number
Returns
Section titled “Returns”void
setEnabled
Section titled “setEnabled”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.
Parameters
Section titled “Parameters”enabled
Section titled “enabled”boolean
Returns
Section titled “Returns”void
waitFor
Section titled “waitFor”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.
Parameters
Section titled “Parameters”pattern
Section titled “pattern”string | RegExp
options?
Section titled “options?”source?
Section titled “source?”"scene" | "entity" | "bus"
withinFrames?
Section titled “withinFrames?”number
Returns
Section titled “Returns”Promise<EventLogEntry>
expect
Section titled “expect”expect:
ExpectStatic
Defined in: tools/lab/src/grammar/drive.ts:123
Jest-style assertions: expect(hp).toBeLessThan(before).
framesUsed
Section titled “framesUsed”
readonlyframesUsed: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
Section titled “pointer”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.
Parameters
Section titled “Parameters”target
Section titled “target”InspectorPointerTarget
InspectorPointerButtonOpts
Returns
Section titled “Returns”InspectorPointerHit
down: (
target,opts?) =>InspectorPointerHit
Presses a mouse button, left unless opts says otherwise.
Parameters
Section titled “Parameters”target
Section titled “target”InspectorPointerTarget
InspectorPointerButtonOpts
Returns
Section titled “Returns”InspectorPointerHit
hitTest
Section titled “hitTest”hitTest: (
target) =>InspectorPointerHit
Resolves target and reports what is under it, dispatching nothing.
Parameters
Section titled “Parameters”target
Section titled “target”InspectorPointerTarget
Returns
Section titled “Returns”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.
Parameters
Section titled “Parameters”target
Section titled “target”InspectorPointerTarget
Returns
Section titled “Returns”InspectorPointerHit
up: (
target,opts?) =>InspectorPointerHit
Releases a mouse button, left unless opts says otherwise.
Parameters
Section titled “Parameters”target
Section titled “target”InspectorPointerTarget
InspectorPointerButtonOpts
Returns
Section titled “Returns”InspectorPointerHit
scene:
Scene
Defined in: tools/lab/src/grammar/drive.ts:78
The scene the run drives. findByKey reaches what the scenario spawned.
Methods
Section titled “Methods”capture()
Section titled “capture()”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.
Parameters
Section titled “Parameters”label?
Section titled “label?”string
Returns
Section titled “Returns”Promise<string>
step()
Section titled “step()”step(
frames?,opts?):Promise<void>
Defined in: tools/lab/src/grammar/drive.ts:116
Advances frames frames, one at a time.
Parameters
Section titled “Parameters”frames?
Section titled “frames?”number
Returns
Section titled “Returns”Promise<void>
until()
Section titled “until()”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).
Parameters
Section titled “Parameters”predicate
Section titled “predicate”() => boolean
Returns
Section titled “Returns”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.