@threenative/playtest API
Every public function and class in @threenative/playtest. Scenario-driven playtest harness for Three.js games. Runs on plain Three.js with zero ThreeNative dependencies.
On this page
Generated from the engine's capability manifest: 88 functions and 15 classes. Each entry is the exported signature, what it is for, and a working example. Start with the package overview.
assertJsonSafe
Validate JSON-safe bridge messages and protocol sizes.
function assertJsonSafe(value: unknown, path = "$"): asserts value is JsonValueUse it to
- send a safe observation over the playtest bridge
- reject an oversized or cyclic playtest payload
- validate entity components and gameplay observations before crossing the bridge
Example
assertJsonSafe({ score: 10 });Good to know
- bridge values must be JSON-shaped
- throws instead of silently dropping the offending field
DeviceMetricsError
Measure and judge device thermal, power and battery state around a device playtest run.
class DeviceMetricsError extends ErrorUse it to
- find out whether an Android run was throttled or started hot
- read battery temperature, current draw or per-rail power for a run
Example
const verdict = summarizeDeviceMetrics(observation.samples);Good to know
- a reading the device does not expose reports unavailable, never zero
- a run that started hot or whose thermal status rose is flagged as confounded
DeviceMetricsRecorder
Measure and judge device thermal, power and battery state around a device playtest run.
class DeviceMetricsRecorderUse it to
- find out whether an Android run was throttled or started hot
- read battery temperature, current draw or per-rail power for a run
Example
const verdict = summarizeDeviceMetrics(observation.samples);Good to know
- a reading the device does not expose reports unavailable, never zero
- a run that started hot or whose thermal status rose is flagged as confounded
evaluateRichPlaytestAssertions
Evaluate rich semantic assertions against captured observations.
function evaluateRichPlaytestAssertions(input:Use it to
- assert movement, visibility, or diagnostics in a playtest
- turn a scenario observation into a pass or failure
Example
const result = evaluateRichPlaytestAssertions(input);Good to know
- malformed or empty assertions fail closed
invalidScenario
Construct a named invalid-scenario error without loading or executing a scenario.
function invalidScenario(scenarioPath: string, message: string): PlaytestScenarioErrorUse it to
- construct a validation error for malformed scenario input
Example
import { invalidScenario } from "@threenative/playtest";
throw invalidScenario("smoke.playtest.json", "Expected a non-empty assertion set");Good to know
- returns an error; the caller must throw it
jsonByteLength
Validate JSON-safe bridge messages and protocol sizes.
function jsonByteLength(value: JsonValue): numberUse it to
- send a safe observation over the playtest bridge
- reject an oversized or cyclic playtest payload
- check a runtime observation against the protocol payload limit before sampling
Example
assertJsonSafe({ score: 10 });Good to know
- bridge values must be JSON-shaped
loadPlaytestScenario
Load and validate a scenario and its referenced evidence before running it.
async function loadPlaytestScenario(projectPath: string, scenarioPath: string): Promise<IPlaytestScenario>Use it to
- create a browser or device playtest scenario
- load a deterministic tick-based playtest scenario
Example
import { loadPlaytestScenario } from "@threenative/playtest";
const scenario = await loadPlaytestScenario(process.cwd(), "playtests/smoke.playtest.json");Good to know
- unknown scenario keys and missing referenced evidence fail closed
- loading validates the fixture; use the runner to execute it
missingPlaytestCapabilities
Validate and inspect playtest capability declarations.
function missingPlaytestCapabilities(required: readonly string[], available: readonly string[]): string[]Use it to
- check whether a scenario's required capabilities are installed
- report unknown or missing playtest capabilities
Example
const missing = missingPlaytestCapabilities(required, available);parseDeviceBattery
Measure and judge device thermal, power and battery state around a device playtest run.
function parseDeviceBattery(output: string): IPlaytestDeviceBatteryUse it to
- find out whether an Android run was throttled or started hot
- read battery temperature, current draw or per-rail power for a run
Example
const verdict = summarizeDeviceMetrics(observation.samples);Good to know
- a reading the device does not expose reports unavailable, never zero
- a run that started hot or whose thermal status rose is flagged as confounded
parseDeviceCurrent
Measure and judge device thermal, power and battery state around a device playtest run.
function parseDeviceCurrent(output: string): PlaytestDeviceMeasurement<number>Use it to
- find out whether an Android run was throttled or started hot
- read battery temperature, current draw or per-rail power for a run
Example
const verdict = summarizeDeviceMetrics(observation.samples);Good to know
- a reading the device does not expose reports unavailable, never zero
- a run that started hot or whose thermal status rose is flagged as confounded
parseDevicePowerRails
Measure and judge device thermal, power and battery state around a device playtest run.
function parseDevicePowerRails(output: string): PlaytestDevicePowerRailsUse it to
- find out whether an Android run was throttled or started hot
- read battery temperature, current draw or per-rail power for a run
Example
const verdict = summarizeDeviceMetrics(observation.samples);Good to know
- a reading the device does not expose reports unavailable, never zero
- a run that started hot or whose thermal status rose is flagged as confounded
parseDeviceThermal
Measure and judge device thermal, power and battery state around a device playtest run.
function parseDeviceThermal(output: string): IPlaytestDeviceThermalUse it to
- find out whether an Android run was throttled or started hot
- read battery temperature, current draw or per-rail power for a run
Example
const verdict = summarizeDeviceMetrics(observation.samples);Good to know
- a reading the device does not expose reports unavailable, never zero
- a run that started hot or whose thermal status rose is flagged as confounded
playtestDiagnostic
Create a structured playtest diagnostic.
function playtestDiagnostic( code: PlaytestDiagnosticCode, message: string, instruction: string, details: Pick<IPlaytestProtocolDiagnostic, "capability" | "path"> &Use it to
- report a named runtime diagnostic to a scenario
- explain why a playtest assertion cannot pass
Example
playtestDiagnostic("TN_PLAYTEST_CAPABILITY_MISSING", "body missing", "register rapier() before adding bodies");PlaytestScenarioError
Carry a structured scenario validation diagnostic as an error.
class PlaytestScenarioError extends ErrorUse it to
- catch a structured playtest scenario validation error
Example
import { PlaytestScenarioError } from "@threenative/playtest";
const error = new PlaytestScenarioError({ code: "TN_PLAYTEST_SCENARIO_INVALID", message: "Invalid fixture", severity: "error", suggestion: "Fix the fixture" });Good to know
- the diagnostic describes a failed load, not a successfully executed scenario
playtestStepHoldTicks
Read a validated step's input-hold duration in simulation ticks.
function playtestStepHoldTicks(step: IPlaytestStep, fallback = 1): numberUse it to
- read the deterministic number of ticks to hold a playtest input
Example
import { playtestStepHoldTicks } from "@threenative/playtest";
const ticks = playtestStepHoldTicks({ kind: "input", press: "KeyW", holdTicks: 30, release: true });Good to know
- reads the duration only; the runner advances the simulation
playtestStepWaitTicks
Read a validated step's no-input duration in simulation ticks.
function playtestStepWaitTicks(step: IPlaytestStep): numberUse it to
- wait or hold a game for a deterministic number of ticks
Example
import { playtestStepWaitTicks } from "@threenative/playtest";
const ticks = playtestStepWaitTicks({ kind: "wait", waitTicks: 30, release: true });Good to know
- reads the wait duration only; the runner advances the simulation
rejectUnknownKeys
Reject object keys outside the explicitly allowed scenario fields.
function rejectUnknownKeys( value: Record<string, unknown>, allowedKeys: readonly string[], scenarioPath: string, objectPath: string, ): voidUse it to
- reject an unknown field while validating a scenario object
Example
import { rejectUnknownKeys } from "@threenative/playtest";
rejectUnknownKeys({ name: "smoke" }, ["name"], "smoke.playtest.json", "scenario");Good to know
- throws an invalid-scenario error on the first unknown key
requiredPlaytestCapabilities
Evaluate rich semantic assertions against captured observations.
function requiredPlaytestCapabilities( scenario: IPlaytestScenario, target?: string, ): PlaytestCapability[]Use it to
- assert movement, visibility, or diagnostics in a playtest
- turn a scenario observation into a pass or failure
Example
const result = evaluateRichPlaytestAssertions(input);Good to know
- malformed or empty assertions fail closed
resolveDiagnosticsPolicy
Resolve the effective diagnostics policy for a run, with fail-closed defaults applied.
function resolveDiagnosticsPolicy( policy: IPlaytestDiagnosticsAssertion | undefined, target?: string, ): IPlaytestDiagnosticsPolicyUse it to
- judge captured console, network, or runtime diagnostics for a playtest
Example
const policy = resolveDiagnosticsPolicy(scenario.assert?.diagnostics);Good to know
- absent policy fields default to rejecting errors
summarizeDeviceMetrics
Measure and judge device thermal, power and battery state around a device playtest run.
function summarizeDeviceMetrics( samples: readonly IPlaytestDeviceMetricsSample[], ): IPlaytestDeviceMetricsVerdictUse it to
- find out whether an Android run was throttled or started hot
- read battery temperature, current draw or per-rail power for a run
Example
const verdict = summarizeDeviceMetrics(observation.samples);Good to know
- a reading the device does not expose reports unavailable, never zero
- a run that started hot or whose thermal status rose is flagged as confounded
unknownPlaytestCapabilities
Validate and inspect playtest capability declarations.
function unknownPlaytestCapabilities(capabilities: readonly string[]): string[]Use it to
- check whether a scenario's required capabilities are installed
- report unknown or missing playtest capabilities
Example
const missing = missingPlaytestCapabilities(required, available);assertCaptureNotBlank
Fail closed when a screenshot is blank or uniform.
function assertCaptureNotBlank(png: Buffer, label: string): ICaptureFrameStatsUse it to
- guard a visual playtest against a blank frame
- prove a screenshot contains more than a loading surface
Example
assertCaptureNotBlank(png, "first frame");Good to know
- the assertion throws instead of returning a false pass
assertFrameShowsSomething
Fail closed when a screenshot is blank or uniform.
assertFrameShowsSomething = assertCaptureNotBlankUse it to
- guard a visual playtest against a blank frame
- prove a screenshot contains more than a loading surface
Example
assertFrameShowsSomething(png, "first frame");Good to know
- the assertion throws instead of returning a false pass
CaptureGuardError
Explain why a captured frame failed the non-blank guard.
class CaptureGuardError extends ErrorUse it to
- fail a visual test when the rendered frame is blank
- include capture statistics in a playtest error
Example
throw new CaptureGuardError("menu", "no bright pixels");collectRegionalTone
Collect opt-in regional tone observations from the same acquired PNG.
function collectRegionalTone( png: Buffer, assertions: readonly IPlaytestToneAssertion[], label: string, atStep?: string, ): IPlaytestRegionalToneObservation[]Use it to
- measure a specified pixel crop in a captured playtest frame
Example
collectRegionalTone(png, assertions, "character", "posed");Good to know
- does not acquire another screenshot or alter frame timing
inspectFrame
Inspect a PNG frame for visible pixels and luminance variation.
function inspectFrame(png: Buffer): ICaptureFrameStatsUse it to
- measure whether a screenshot contains a rendered game
- diagnose a uniform or blank capture
Example
const stats = inspectFrame(png);assertJsonSafe
Reject any value that would not survive JSON serialization.
function assertJsonSafe(value: unknown, path = "$"): asserts value is JsonValueUse it to
- validate entity components and gameplay observations before crossing the bridge
Example
assertJsonSafe(snapshot, "$.components");Good to know
- throws instead of silently dropping the offending field
jsonByteLength
Measure a payload's wire size in bytes.
function jsonByteLength(value: JsonValue): numberUse it to
- check a runtime observation against the protocol payload limit before sampling
Example
const bytes = jsonByteLength(observation);requestedPlaytestClockMode
The clock the host asked for, or undefined for the default deterministic run. wall-clock is the production profile's opt-in and the only one this protocol has. An unrecognised value throws instead of falling back, because a misspelling that quietly left the loop frozen would publish a frame rate for a game that was not playing. Read at the moment it is needed rather than once at install: a request that arrives after the producer was installed is still a request, and a producer that missed it would judge a live frame pump by a count it never asked for.
function requestedPlaytestClockMode(): PlaytestClockMode | undefinedUse it to
- report which clock a playtest producer is really running on, before judging its ticks
Example
if (requestedPlaytestClockMode() === "wall-clock") host.pumpDrivesTheSimulation();Good to know
- throws on an unrecognised value instead of falling back to a fixed-step run
AdbAndroidDriver
Drive and inspect Android playtest transport.
class AdbAndroidDriver implements IAndroidDriverUse it to
- run a scenario on an Android emulator or device
- parse Android console diagnostics
Example
const adb = discoverAdb(process.env);Good to know
- Android evidence must name its target and transport
advanceFixedStep
Execute scenario steps, assertions, and evidence capture.
async function advanceFixedStep( page: Page, bridge: Pick<IPlaytestBridgeClient, "advance">, ticks: number, ): Promise<void>Use it to
- run a complete browser or device playtest
- capture diagnostics and screenshots from a managed server
Example
const report = await runStandalonePlaytest(options);Good to know
- missing observations and malformed assertions fail closed
advanceTimeoutMs
Connect a Playwright page to a playtest bridge.
function advanceTimeoutMs( ticks: number, perTickMs: number = PLAYTEST_ADVANCE_TICK_BUDGET_MS, ): numberUse it to
- run a browser scenario against a game
- inspect bridge diagnostics from a runner
Example
const bridge = await connectPlaytestBridge(page, scenario);Good to know
- the bridge must answer the handshake or the run fails
androidMailboxPaths
Resolve a native device transport and its mailbox paths.
function androidMailboxPaths( packageName: string, root = `/sdcard/Android/data/$Use it to
- connect a native host to the playtest runner
- validate an Android or iOS device endpoint
Example
const paths = deviceMailboxPaths(projectRoot);Good to know
- paths stay inside the managed artifact directory
androidTouchBatches
Drive and inspect Android playtest transport.
function androidTouchBatches( identity: readonly string[], positions: readonly string[], ): string[][]Use it to
- run a scenario on an Android emulator or device
- parse Android console diagnostics
Example
const adb = discoverAdb(process.env);Good to know
- Android evidence must name its target and transport
batchArtifactDirectory
Execute scenario steps, assertions, and evidence capture.
function batchArtifactDirectory(base: string, scenarioPath: string, index: number): stringUse it to
- run a complete browser or device playtest
- capture diagnostics and screenshots from a managed server
Example
const report = await runStandalonePlaytest(options);Good to know
- missing observations and malformed assertions fail closed
boundedTeardownStep
Execute scenario steps, assertions, and evidence capture.
async function boundedTeardownStep( step: Promise<unknown> | undefined, timeoutMs: number, ): Promise<boolean>Use it to
- run a complete browser or device playtest
- capture diagnostics and screenshots from a managed server
Example
const report = await runStandalonePlaytest(options);Good to know
- missing observations and malformed assertions fail closed
bridgeWaitTimeoutMs
Connect a Playwright page to a playtest bridge.
function bridgeWaitTimeoutMs( operationMs: number = PLAYTEST_PROTOCOL_LIMITS.operationTimeoutMs, ): numberUse it to
- run a browser scenario against a game
- inspect bridge diagnostics from a runner
Example
const bridge = await connectPlaytestBridge(page, scenario);Good to know
- the bridge must answer the handshake or the run fails
buildReport
Execute scenario steps, assertions, and evidence capture.
function buildReport( config: IStandalonePlaytestConfig, scenario: IPlaytestScenario, beforeSnapshot: IPlaytestObservationSnapshot | undefined, afterSnapshot: IPlaytestObservationSnapshot | undefined, consoleEntries: IRunnerConsoleEntry[], networkEntries: Array<Use it to
- run a complete browser or device playtest
- capture diagnostics and screenshots from a managed server
Example
const report = await runStandalonePlaytest(options);Good to know
- missing observations and malformed assertions fail closed
captureVisualSurface
Execute scenario steps, assertions, and evidence capture.
async function captureVisualSurface( page: Page, artifactPath?: string, ): Promise<Buffer | undefined>Use it to
- run a complete browser or device playtest
- capture diagnostics and screenshots from a managed server
Example
const report = await runStandalonePlaytest(options);Good to know
- missing observations and malformed assertions fail closed
connectPlaytestBridge
Connect a Playwright page to a playtest bridge.
async function connectPlaytestBridge( page: Page, scenario: IPlaytestScenario, timeoutMs: number = PLAYTEST_PROTOCOL_LIMITS.operationTimeoutMs, ): Promise<IPlaytestBridgeClient | undefined>Use it to
- run a browser scenario against a game
- inspect bridge diagnostics from a runner
Example
const bridge = await connectPlaytestBridge(page, scenario);Good to know
- the bridge must answer the handshake or the run fails
connectPlaytestBridgeTransport
Connect a Playwright page to a playtest bridge.
async function connectPlaytestBridgeTransport( transport: IBridgeTransport, scenario: IPlaytestScenario, timeoutMs: number = bridgeWaitTimeoutMs(), target?: string, ): Promise<IPlaytestBridgeClient | undefined>Use it to
- run a browser scenario against a game
- inspect bridge diagnostics from a runner
Example
const bridge = await connectPlaytestBridge(page, scenario);Good to know
- the bridge must answer the handshake or the run fails
decideDisplayStrategy
Decide which display a pixel-producing run paints on, the same decision the runner makes.
function decideDisplayStrategy(input: IDisplayDecisionInput): IDisplayStrategyUse it to
- judge whether a measured frame rate came from a display that can carry one
Example
import { decideDisplayStrategy } from "@threenative/playtest/runner";
const lane = decideDisplayStrategy({ env: process.env, platform: "linux" });
if (lane.kind === "private-xvfb") throw new Error("refuse to judge this frame rate");Good to know
- a private Xvfb is software, so a rate read there measures the X server
DesktopPlaytestDriver
Drive a local desktop playtest mailbox.
class DesktopPlaytestDriver implements IDevicePlaytestDriverUse it to
- run a desktop target through the playtest protocol
- exchange observations with a native desktop host
Example
const driver = new DesktopPlaytestDriver(options);Good to know
- the mailbox lifecycle must be disposed after the run
DeviceBridgeTransport
Resolve a native device transport and its mailbox paths.
class DeviceBridgeTransport implements IDevicePlaytestTransportUse it to
- connect a native host to the playtest runner
- validate an Android or iOS device endpoint
Example
const paths = deviceMailboxPaths(projectRoot);Good to know
- paths stay inside the managed artifact directory
deviceMailboxPaths
Resolve a native device transport and its mailbox paths.
function deviceMailboxPaths(root: string): IDeviceMailboxPathsUse it to
- connect a native host to the playtest runner
- validate an Android or iOS device endpoint
Example
const paths = deviceMailboxPaths(projectRoot);Good to know
- paths stay inside the managed artifact directory
DeviceMailboxTransport
Resolve a native device transport and its mailbox paths.
class DeviceMailboxTransport implements IDevicePlaytestTransportUse it to
- connect a native host to the playtest runner
- validate an Android or iOS device endpoint
Example
const paths = deviceMailboxPaths(projectRoot);Good to know
- paths stay inside the managed artifact directory
deviceTimeoutDiagnostic
Resolve a native device transport and its mailbox paths.
function deviceTimeoutDiagnostic( diagnostic: IPlaytestProtocolDiagnostic, hostAlive: boolean | undefined, lastConsoleLines: readonly string[], ): IPlaytestProtocolDiagnosticUse it to
- connect a native host to the playtest runner
- validate an Android or iOS device endpoint
Example
const paths = deviceMailboxPaths(projectRoot);Good to know
- paths stay inside the managed artifact directory
discoverAdb
Drive and inspect Android playtest transport.
function discoverAdb(environment: NodeJS.ProcessEnv = process.env): stringUse it to
- run a scenario on an Android emulator or device
- parse Android console diagnostics
Example
const adb = discoverAdb(process.env);Good to know
- Android evidence must name its target and transport
failedDiagnosticsAssertion
Execute scenario steps, assertions, and evidence capture.
function failedDiagnosticsAssertion(policy: IPlaytestDiagnosticsPolicy): IPlaytestAssertionResultUse it to
- run a complete browser or device playtest
- capture diagnostics and screenshots from a managed server
Example
const report = await runStandalonePlaytest(options);Good to know
- missing observations and malformed assertions fail closed
formatPipelineSummary
Parse and explain bounded shader-compilation captures.
function formatPipelineSummary(summary: IPipelineSummary): stringUse it to
- diagnose a slow shader-heavy launch from one browser or native capture
- reconcile pipeline creation counts and compile timing
Example
summarizePipelineCapture(parsePipelineCapture(captureText));Good to know
- incomplete or malformed captures never become a successful empty report
formatUsage
Parse standalone playtest runner configuration.
function formatUsage(): stringUse it to
- invoke the playtest CLI from a scaffold
- validate runner flags before launching a browser
Example
const config = parseStandalonePlaytestArgs(argv);Good to know
- invalid flags throw a named usage error
handlePlaytestSignal
Execute scenario steps, assertions, and evidence capture.
async function handlePlaytestSignal( teardown: (stopManagedServer: boolean) => Promise<void>, setExitCode: (code: number) => void = (code) =>Use it to
- run a complete browser or device playtest
- capture diagnostics and screenshots from a managed server
Example
const report = await runStandalonePlaytest(options);Good to know
- missing observations and malformed assertions fail closed
initStandalonePlaytest
Initialize the standalone playtest files for a project.
async function initStandalonePlaytest(projectPath = process.cwd()): Promise<Use it to
- add the runner contract to a new game
- create a starter scenario fixture
Example
await initStandalonePlaytest(projectPath);Good to know
- generated scenarios must contain real assertions
isRuntimeReadout
Execute scenario steps, assertions, and evidence capture.
function isRuntimeReadout(entry: unknown): booleanUse it to
- run a complete browser or device playtest
- capture diagnostics and screenshots from a managed server
Example
const report = await runStandalonePlaytest(options);Good to know
- missing observations and malformed assertions fail closed
keyboardIsShown
Drive and inspect Android playtest transport.
function keyboardIsShown(dump: string): booleanUse it to
- run a scenario on an Android emulator or device
- parse Android console diagnostics
Example
const adb = discoverAdb(process.env);Good to know
- Android evidence must name its target and transport
LocalDeviceMailbox
Drive a local desktop playtest mailbox.
class LocalDeviceMailboxUse it to
- run a desktop target through the playtest protocol
- exchange observations with a native desktop host
Example
const driver = new DesktopPlaytestDriver(options);Good to know
- the mailbox lifecycle must be disposed after the run
ManagedServerError
Execute scenario steps, assertions, and evidence capture.
class ManagedServerError extends ErrorUse it to
- run a complete browser or device playtest
- capture diagnostics and screenshots from a managed server
Example
const report = await runStandalonePlaytest(options);Good to know
- missing observations and malformed assertions fail closed
openPageAndConnectBridge
Execute scenario steps, assertions, and evidence capture.
async function openPageAndConnectBridge( page: Page, config: IStandalonePlaytestConfig, scenario: IPlaytestScenario, ): Promise<IPlaytestBridgeClient | undefined>Use it to
- run a complete browser or device playtest
- capture diagnostics and screenshots from a managed server
Example
const report = await runStandalonePlaytest(options);Good to know
- missing observations and malformed assertions fail closed
pageLifecycleDiagnostic
Execute scenario steps, assertions, and evidence capture.
function pageLifecycleDiagnostic( error: unknown, lifecycle: IPageLifecycle, url: string, ): IPlaytestProtocolDiagnostic | undefinedUse it to
- run a complete browser or device playtest
- capture diagnostics and screenshots from a managed server
Example
const report = await runStandalonePlaytest(options);Good to know
- missing observations and malformed assertions fail closed
parseAndroidConsole
Drive and inspect Android playtest transport.
function parseAndroidConsole(output: string): Array<Use it to
- run a scenario on an Android emulator or device
- parse Android console diagnostics
Example
const adb = discoverAdb(process.env);Good to know
- Android evidence must name its target and transport
parseAndroidTouchViewport
Drive and inspect Android playtest transport.
function parseAndroidTouchViewport(output: string): IAndroidTouchViewportUse it to
- run a scenario on an Android emulator or device
- parse Android console diagnostics
Example
const adb = discoverAdb(process.env);Good to know
- Android evidence must name its target and transport
parseLaunchedPid
Drive and inspect iOS simulator playtest transport.
function parseLaunchedPid(output: string): stringUse it to
- run a scenario on the iOS simulator
- parse the launched native process identifier
Example
const driver = new XcrunIosDriver(options);Good to know
- simulator evidence does not claim physical-device proof
parsePipelineCapture
Parse and explain bounded shader-compilation captures.
function parsePipelineCapture(input: string | unknown): IPipelineCaptureUse it to
- diagnose a slow shader-heavy launch from one browser or native capture
- reconcile pipeline creation counts and compile timing
Example
summarizePipelineCapture(parsePipelineCapture(captureText));Good to know
- incomplete or malformed captures never become a successful empty report
parsePipelineEventMarkers
Parse and explain bounded shader-compilation captures.
function parsePipelineEventMarkers(text: string): IPipelineCaptureEvent[]Use it to
- diagnose a slow shader-heavy launch from one browser or native capture
- reconcile pipeline creation counts and compile timing
Example
summarizePipelineCapture(parsePipelineCapture(captureText));Good to know
- incomplete or malformed captures never become a successful empty report
parseStandalonePlaytestArgs
Parse standalone playtest runner configuration.
function parseStandalonePlaytestArgs(argv: readonly string[], cwd = process.cwd()): IStandalonePlaytestConfigUse it to
- invoke the playtest CLI from a scaffold
- validate runner flags before launching a browser
Example
const config = parseStandalonePlaytestArgs(argv);Good to know
- invalid flags throw a named usage error
PlaytestBridgeError
Connect a Playwright page to a playtest bridge.
class PlaytestBridgeError extends ErrorUse it to
- run a browser scenario against a game
- inspect bridge diagnostics from a runner
Example
const bridge = await connectPlaytestBridge(page, scenario);Good to know
- the bridge must answer the handshake or the run fails
PlaytestCliUsageError
Parse standalone playtest runner configuration.
class PlaytestCliUsageError extends ErrorUse it to
- invoke the playtest CLI from a scaffold
- validate runner flags before launching a browser
Example
const config = parseStandalonePlaytestArgs(argv);Good to know
- invalid flags throw a named usage error
playtestStepDrivesMovement
Execute scenario steps, assertions, and evidence capture.
function playtestStepDrivesMovement( step: IPlaytestScenario["steps"][number], hasHeldInput: boolean, ): booleanUse it to
- run a complete browser or device playtest
- capture diagnostics and screenshots from a managed server
Example
const report = await runStandalonePlaytest(options);Good to know
- missing observations and malformed assertions fail closed
PlaywrightTransport
Connect a Playwright page to a playtest bridge.
class PlaywrightTransport implements IBridgeTransportUse it to
- run a browser scenario against a game
- inspect bridge diagnostics from a runner
Example
const bridge = await connectPlaytestBridge(page, scenario);Good to know
- the bridge must answer the handshake or the run fails
preflightDisplay
Execute scenario steps, assertions, and evidence capture.
function preflightDisplay( config: Pick<IStandalonePlaytestConfig, "headless">, scenario: Pick<IPlaytestScenario, "artifacts" | "assert" | "steps">, environment: NodeJS.ProcessEnv = process.env, platform = process.platform, ): IPlaytestDiagnostic | undefinedUse it to
- run a complete browser or device playtest
- capture diagnostics and screenshots from a managed server
Example
const report = await runStandalonePlaytest(options);Good to know
- missing observations and malformed assertions fail closed
reconcileBrowserPointers
Compare pointer snapshots and produce down, move, and up transitions.
function reconcileBrowserPointers( previous: ReadonlyMap<number, Required<IPlaytestPointer>>, next: readonly IPlaytestPointer[], ): IBrowserPointerChange[]Use it to
- reconcile pointer contacts into down move and up events
Example
import { reconcileBrowserPointers } from "@threenative/playtest/runner";
const changes = reconcileBrowserPointers(new Map(), [{ id: 1, x: 20, y: 30 }]);Good to know
- returns changes only; the caller dispatches them and retains the next snapshot
recordToScenario
Convert captured runner observations into a replay scenario.
function recordToScenario( value: unknown, scenarioPath = "recording.json", oracleValue?: unknown, ): IPlaytestScenarioUse it to
- preserve a failing playtest as a replay fixture
- require assertions before recording a scenario
Example
const scenario = recordToScenario(recording);Good to know
- an empty assertion set is a failure
requireAssertions
Convert captured runner observations into a replay scenario.
function requireAssertions( value: IPlaytestScenario["assert"], scenarioPath: string, ): NonNullable<IPlaytestScenario["assert"]>Use it to
- preserve a failing playtest as a replay fixture
- require assertions before recording a scenario
Example
const scenario = recordToScenario(recording);Good to know
- an empty assertion set is a failure
resolveBrowserArguments
Copy the selected Chromium arguments without silently enabling a rendering recipe.
function resolveBrowserArguments(browserArgs: readonly string[] | undefined): string[]Use it to
- run a browser playtest with Vulkan WebGPU
Example
import { resolveBrowserArguments, WEBGPU_BROWSER_ARGS } from "@threenative/playtest/runner";
const args = resolveBrowserArguments(WEBGPU_BROWSER_ARGS);Good to know
- pass WEBGPU_BROWSER_ARGS explicitly; undefined selects no additional arguments
- inspect the observed adapter before claiming hardware GPU evidence
resolveManagedServerCommand
Execute scenario steps, assertions, and evidence capture.
function resolveManagedServerCommand( config: IStandalonePlaytestConfig, dynamicPort?: number, ): stringUse it to
- run a complete browser or device playtest
- capture diagnostics and screenshots from a managed server
Example
const report = await runStandalonePlaytest(options);Good to know
- missing observations and malformed assertions fail closed
resolveManagedServerConfig
Execute scenario steps, assertions, and evidence capture.
async function resolveManagedServerConfig( config: IStandalonePlaytestConfig, ): Promise<IStandalonePlaytestConfig>Use it to
- run a complete browser or device playtest
- capture diagnostics and screenshots from a managed server
Example
const report = await runStandalonePlaytest(options);Good to know
- missing observations and malformed assertions fail closed
rotatedTouchPosition
Drive and inspect Android playtest transport.
function rotatedTouchPosition(x: number, y: number, rotation: number): [number, number]Use it to
- run a scenario on an Android emulator or device
- parse Android console diagnostics
Example
const adb = discoverAdb(process.env);Good to know
- Android evidence must name its target and transport
runAndroidPlaytest
Run a playtest on Android through the configured device transport.
async function runAndroidPlaytest( config: IStandalonePlaytestConfig, dependencies: IAndroidPlaytestDependencies =Use it to
- execute a scenario on an Android target
- collect Android playtest artifacts
Example
await runAndroidPlaytest(options);Good to know
- the app bundle and device transport must be prepared
runDesktopPlaytest
Run a desktop playtest and collect its report.
async function runDesktopPlaytest( config: IStandalonePlaytestConfig, dependencies: IDesktopPlaytestDependencies =Use it to
- execute a scenario against the desktop host
- verify native desktop behavior from the same scenario
Example
await runDesktopPlaytest(options);Good to know
- the desktop host must be built before launching
runDevicePlaytest
Run a playtest on Android through the configured device transport.
async function runDevicePlaytest( config: IStandalonePlaytestConfig, target: IDevicePlaytestTarget, ): Promise<IStandalonePlaytestReport>Use it to
- execute a scenario on an Android target
- collect Android playtest artifacts
Example
await runAndroidPlaytest(options);Good to know
- the app bundle and device transport must be prepared
runIosPlaytest
Run a playtest on the iOS simulator or device transport.
async function runIosPlaytest( config: IStandalonePlaytestConfig, dependencies: IIosPlaytestDependencies =Use it to
- execute a scenario on an iOS target
- collect iOS playtest artifacts
Example
await runIosPlaytest(options);Good to know
- identify simulator versus physical transport in evidence
runStandalonePlaytest
Execute scenario steps, assertions, and evidence capture.
async function runStandalonePlaytest( config: IStandalonePlaytestConfig, options: IStandalonePlaytestRunOptions =Use it to
- run a complete browser or device playtest
- capture diagnostics and screenshots from a managed server
Example
const report = await runStandalonePlaytest(options);Good to know
- missing observations and malformed assertions fail closed
runStandalonePlaytests
Execute scenario steps, assertions, and evidence capture.
async function runStandalonePlaytests( config: IStandalonePlaytestConfig, ): Promise<readonly IStandalonePlaytestReport[]>Use it to
- run a complete browser or device playtest
- capture diagnostics and screenshots from a managed server
Example
const report = await runStandalonePlaytest(options);Good to know
- missing observations and malformed assertions fail closed
softwareAdapterName
Identify a software renderer in the fields reported by adapter.info.
function softwareAdapterName(adapter: Readonly<Record<string, string>> | undefined): string | undefinedUse it to
- reject a SwiftShader adapter as evidence
Example
import { softwareAdapterName } from "@threenative/playtest/runner";
const software = softwareAdapterName({ architecture: "swiftshader" });Good to know
- undefined means no software name was found, not proof of a hardware adapter
substituteManagedPort
Execute scenario steps, assertions, and evidence capture.
function substituteManagedPort(command: string, port: number): stringUse it to
- run a complete browser or device playtest
- capture diagnostics and screenshots from a managed server
Example
const report = await runStandalonePlaytest(options);Good to know
- missing observations and malformed assertions fail closed
summarizePipelineCapture
Parse and explain bounded shader-compilation captures.
function summarizePipelineCapture(capture: IPipelineCapture): IPipelineSummaryUse it to
- diagnose a slow shader-heavy launch from one browser or native capture
- reconcile pipeline creation counts and compile timing
Example
summarizePipelineCapture(parsePipelineCapture(captureText));Good to know
- incomplete or malformed captures never become a successful empty report
tapCommand
Drive and inspect Android playtest transport.
function tapCommand(x: number, y: number): string[]Use it to
- run a scenario on an Android emulator or device
- parse Android console diagnostics
Example
const adb = discoverAdb(process.env);Good to know
- Android evidence must name its target and transport
touchPositionForViewport
Drive and inspect Android playtest transport.
function touchPositionForViewport( x: number, y: number, viewport: IAndroidTouchViewport, rotationOverride?: number, ): [number, number]Use it to
- run a scenario on an Android emulator or device
- parse Android console diagnostics
Example
const adb = discoverAdb(process.env);Good to know
- Android evidence must name its target and transport
touchRotationFromWindowDump
Drive and inspect Android playtest transport.
function touchRotationFromWindowDump(dump: string): number | undefinedUse it to
- run a scenario on an Android emulator or device
- parse Android console diagnostics
Example
const adb = discoverAdb(process.env);Good to know
- Android evidence must name its target and transport
validateDeviceEndpoint
Resolve a native device transport and its mailbox paths.
function validateDeviceEndpoint(value: string): URLUse it to
- connect a native host to the playtest runner
- validate an Android or iOS device endpoint
Example
const paths = deviceMailboxPaths(projectRoot);Good to know
- paths stay inside the managed artifact directory
viewportPresentationCommands
Drive and inspect Android playtest transport.
function viewportPresentationCommands( viewport:Use it to
- run a scenario on an Android emulator or device
- parse Android console diagnostics
Example
const adb = discoverAdb(process.env);Good to know
- Android evidence must name its target and transport
viewportPresentationObserved
Drive and inspect Android playtest transport.
function viewportPresentationObserved( override: string | undefined, expected: string | undefined, physical:Use it to
- run a scenario on an Android emulator or device
- parse Android console diagnostics
- verify that an Android device presented the requested viewport
- accept the physical panel size when
wm sizeomits its override line
Example
const adb = discoverAdb(process.env);Good to know
- Android evidence must name its target and transport
viewportRestoreCommands
Drive and inspect Android playtest transport.
function viewportRestoreCommands(): string[][]Use it to
- run a scenario on an Android emulator or device
- parse Android console diagnostics
Example
const adb = discoverAdb(process.env);Good to know
- Android evidence must name its target and transport
withBrowserCapture
Capture a ready ThreeNative game with the runner's display, lock, server and browser ownership.
async function withBrowserCapture<T>( config: IStandalonePlaytestConfig, capture: (session: IBrowserCaptureSession) => Promise<T>, signal?: AbortSignal, ): Promise<T>Use it to
- write a custom browser capture without owning Xvfb or Chromium cleanup
Example
import { parseStandalonePlaytestArgs, withBrowserCapture } from "@threenative/playtest/runner";
const config = parseStandalonePlaytestArgs(["--scenario", "playtests/smoke.playtest.json", "--url", "http://127.0.0.1:5173"]);
await withBrowserCapture(config, async (session) => session.screenshot("ready"));Good to know
- browser only; requires a scenario and runtime.startup; does not execute scenario steps or assertions
- cancellation is checked between resource acquisitions; lock waiting retains its own bounded queue policy
- use session.screenshot for nonblank PNGs; private-display captures are not FPS evidence
- use threenative-playtest trace --url <url> for slow-frame attribution instead of creating another profiler
writeCaptureProvenance
Execute scenario steps, assertions, and evidence capture.
async function writeCaptureProvenance( artifactDirectory: string, provenance: IPlaytestCaptureProvenance, ): Promise<void>Use it to
- run a complete browser or device playtest
- capture diagnostics and screenshots from a managed server
Example
const report = await runStandalonePlaytest(options);Good to know
- missing observations and malformed assertions fail closed
writeObservationArtifacts
Execute scenario steps, assertions, and evidence capture.
async function writeObservationArtifacts( artifactDirectory: string, requested: IPlaytestArtifactRequest | undefined, observations:Use it to
- run a complete browser or device playtest
- capture diagnostics and screenshots from a managed server
Example
const report = await runStandalonePlaytest(options);Good to know
- missing observations and malformed assertions fail closed
XcrunIosDriver
Drive and inspect iOS simulator playtest transport.
class XcrunIosDriver implements IDevicePlaytestDriverUse it to
- run a scenario on the iOS simulator
- parse the launched native process identifier
Example
const driver = new XcrunIosDriver(options);Good to know
- simulator evidence does not claim physical-device proof
adviseThreeRenderWorkload
Explain which render workloads should be collapsed or retained.
function adviseThreeRenderWorkload(input: IRenderAdvisorInput): IRenderAdvisorReportUse it to
- diagnose a slow Three.js scene
- choose a render optimization from observed workload data
Example
const advice = adviseThreeRenderWorkload(input);Good to know
- use measured input rather than visual guesses
connectDevicePlaytestBridge
Connect a device-hosted game to the playtest bridge.
function connectDevicePlaytestBridge( bridge: IPlaytestBridgeV1, endpoint: string, ): IDeviceBridgeInstallationUse it to
- run the same playtest on an Android or iOS target
- read the device bridge endpoint
Example
const connection = connectDevicePlaytestBridge(bridge, endpoint);Good to know
- use the device transport selected by the runner
installThreePlaytestBridge
Install the playtest observation bridge for a plain Three.js game.
function installThreePlaytestBridge(options: IThreePlaytestBridgeOptions): IThreePlaytestBridgeInstallationUse it to
- expose a non-ThreeNative game to the scenario runner
- add semantic observations to a browser playtest
Example
const bridge = installThreePlaytestBridge(options);Good to know
- install once before the runner connects
observeSceneResources
Observe the room a game is played in — lights, materials, fog, background and camera framing.
function observeSceneResources(scene: Scene, camera: Camera): IPlaytestSceneObservationUse it to
- ask why a frame is black or washed out without opening a screenshot
- ask what lights, materials and framing a running game actually has
Example
const room = observeSceneResources(scene, camera);Good to know
- reports counts and names only; it decides nothing about how the game looks
- reports counts and names only; nothing here decides how the game looks
- a walk that hits
SCENE_WALK_OBJECT_CAPreportstruncated: true
readPlaytestEndpoint
Connect a device-hosted game to the playtest bridge.
function readPlaytestEndpoint(): string | undefinedUse it to
- run the same playtest on an Android or iOS target
- read the device bridge endpoint
Example
const connection = connectDevicePlaytestBridge(bridge, endpoint);Good to know
- use the device transport selected by the runner
ThreePlaytestPhysicsRecorder
Record Three.js physics bodies for playtest observations.
class ThreePlaytestPhysicsRecorderUse it to
- assert physics contacts in a plain Three.js game
- capture bounded body state for a scenario
Example
const physics = new ThreePlaytestPhysicsRecorder(worldPhysics);Good to know
- keep recorder limits within the documented caps