Skip to content

SimulatedClock

Defined in: console-sdk/src/testing/simulatedClock.ts:54

The deterministic test clock (SDK_PLAN.md §3.11.2 / §4.8.1). It implements the same Clock interface production uses, so the entire runtime — connect timeouts, reconnect backoff, correlator budgets, link health checks, coalesced store commits, simulated-console frame emission — runs unmodified above it.

Only durations are ever gated: scan surfacing, connect() settling, state flips, and frame delivery resolve via the microtask queue without any advance (§3.11.2’s clock-gating table).

advance(ms): Promise<void>

Defined in: console-sdk/src/testing/simulatedClock.ts:77

Advance simulated time by ms milliseconds, firing every due timeout, interval tick, and frame in timestamp order (FIFO within one timestamp) and awaiting a microtask flush between entries, so promise chains started by each callback settle before the next entry fires. Work scheduled during the walk (cascaded timers, interval reschedules, new frames) fires in the same call when it falls inside the window.

Resolves with now() at exactly start + ms. Rejects with RangeError for negative or non-finite ms, and with Error when another advance() is still in flight (the walk is not reentrant). A callback that throws rejects the walk at that entry — simulated time rests at the failing entry’s timestamp, remaining entries stay queued, and the clock remains usable.

number

Promise<void>


cancelFrame(handle): void

Defined in: console-sdk/src/runtime/clock.ts:73

Cancel a pending frame request. Safe to call after it has fired.

FrameHandle

void

Clock.cancelFrame


clearInterval(handle): void

Defined in: console-sdk/src/runtime/clock.ts:64

Cancel a repeating timer. Safe to call more than once.

IntervalHandle

void

Clock.clearInterval


clearTimeout(handle): void

Defined in: console-sdk/src/runtime/clock.ts:60

Cancel a pending one-shot timer. Safe to call after it has fired.

TimeoutHandle

void

Clock.clearTimeout


now(): number

Defined in: console-sdk/src/testing/simulatedClock.ts:60

Current simulated time in milliseconds. Starts at the configured epoch (default 0) and moves only through SimulatedClock.advance — inside a scheduled callback it reads exactly that entry’s fire time.

number

Clock.now


requestFrame(callback): FrameHandle

Defined in: console-sdk/src/runtime/clock.ts:71

Schedule callback for the next animation frame (used by the frame-coalesced stores, §4.5.1). frameTimeMs is the platform frame timestamp — its timebase is platform-defined, so use it only for intra-frame deltas, never mix it with Clock.now.

(frameTimeMs) => void

FrameHandle

Clock.requestFrame


setInterval(callback, intervalMs): IntervalHandle

Defined in: console-sdk/src/runtime/clock.ts:62

Schedule callback to run every intervalMs milliseconds.

() => void

number

IntervalHandle

Clock.setInterval


setTimeout(callback, delayMs): TimeoutHandle

Defined in: console-sdk/src/runtime/clock.ts:58

Schedule callback to run once, delayMs milliseconds from now.

() => void

number

TimeoutHandle

Clock.setTimeout