Skip to content

API reference / @jsprismarine/script-host / host/gametest

host/gametest ​

Classes ​

Interfaces ​

GameTestHost ​

Defined in: script-host/src/host/gametest.ts:98

What the runner reaches of the runtime that owns it.

Type Parameters ​

Owner ​

Owner

Properties ​

log ​

readonly log: ScriptLog

Defined in: script-host/src/host/gametest.ts:100

world ​

readonly world: ScriptWorld

Defined in: script-host/src/host/gametest.ts:99

Methods ​

call() ​

call(owner, callback, args): GameTestCall

Defined in: script-host/src/host/gametest.ts:107

Calls a pack's callback with the default privilege, as a system task is called. A value it returns that is a handle belongs to the caller.

Parameters ​
owner ​

Owner

callback ​

ScriptHandle

args ​

readonly ScriptValue[]

Returns ​

GameTestCall

What it returned, or the text of what it threw, which the runtime has logged unless it is a GameTestError.

createTest() ​

createTest(owner, run): ScriptHandle

Defined in: script-host/src/host/gametest.ts:109

Makes the Test object a run's test function gets, in its pack.

Parameters ​
owner ​

Owner

run ​

number

Returns ​

ScriptHandle

free() ​

free(handle): void

Defined in: script-host/src/host/gametest.ts:117

Parameters ​
handle ​

ScriptHandle

Returns ​

void

onRejected() ​

onRejected(owner, promise, rejected): void

Defined in: script-host/src/host/gametest.ts:114

Calls rejected with the text of the error a promise of the pack rejects with, in the flush its promise jobs run in.

Parameters ​
owner ​

Owner

promise ​

ScriptHandle

rejected ​

(message) => void

Returns ​

void

structure() ​

structure(owner, path): Uint8Array<ArrayBufferLike> | undefined

Defined in: script-host/src/host/gametest.ts:116

A structure file of the owner's pack, or of another pack of the world when it has none.

Parameters ​
owner ​

Owner

path ​

string

Returns ​

Uint8Array<ArrayBufferLike> | undefined


GameTestOptions ​

Defined in: script-host/src/host/gametest.ts:45

What a RegistrationBuilder sets on a test.

Properties ​

batch? ​

optional batch?: string

Defined in: script-host/src/host/gametest.ts:53

maxTicks ​

maxTicks: number

Defined in: script-host/src/host/gametest.ts:49

required ​

required: boolean

Defined in: script-host/src/host/gametest.ts:54

setupTicks ​

setupTicks: number

Defined in: script-host/src/host/gametest.ts:51

Ticks between placing the structure and calling the test function.

structureLocation? ​

optional structureLocation?: StructurePlacement

Defined in: script-host/src/host/gametest.ts:48

structureName ​

structureName: string

Defined in: script-host/src/host/gametest.ts:47

The structure, as <namespace>:<name>, which is the file structures/<namespace>/<name>.mcstructure.

tags ​

tags: string[]

Defined in: script-host/src/host/gametest.ts:52


GameTestRegistration ​

Defined in: script-host/src/host/gametest.ts:58

One registered test.

Type Parameters ​

Owner ​

Owner

Properties ​

async ​

readonly async: boolean

Defined in: script-host/src/host/gametest.ts:64

Whether the function returns a promise whose rejection fails the test, as registerAsync registers.

fn ​

readonly fn: ScriptHandle

Defined in: script-host/src/host/gametest.ts:62

name ​

readonly name: string

Defined in: script-host/src/host/gametest.ts:61

<testClassName>:<testName>, which /gametest run takes.

options ​

readonly options: GameTestOptions

Defined in: script-host/src/host/gametest.ts:65

owner ​

readonly owner: Owner

Defined in: script-host/src/host/gametest.ts:59


GameTestReply ​

Defined in: script-host/src/host/gametest.ts:121

What /gametest answers: a line of feedback or an error.

Properties ​

message ​

readonly message: string

Defined in: script-host/src/host/gametest.ts:123

ok ​

readonly ok: boolean

Defined in: script-host/src/host/gametest.ts:122


GameTestRun ​

Defined in: script-host/src/host/gametest.ts:77

One run of a test.

Type Parameters ​

Owner ​

Owner

Properties ​

conditions ​

conditions: ScriptHandle[]

Defined in: script-host/src/host/gametest.ts:88

dimension ​

readonly dimension: string

Defined in: script-host/src/host/gametest.ts:80

id ​

readonly id: number

Defined in: script-host/src/host/gametest.ts:78

origin ​

readonly origin: ScriptVector3

Defined in: script-host/src/host/gametest.ts:82

The structure's lowest corner, which the test's relative locations count from.

players ​

players: string[]

Defined in: script-host/src/host/gametest.ts:90

The simulated players the test spawned and has not removed.

registration ​

readonly registration: GameTestRegistration<Owner>

Defined in: script-host/src/host/gametest.ts:79

startTick ​

startTick: number

Defined in: script-host/src/host/gametest.ts:84

state ​

state: GameTestState

Defined in: script-host/src/host/gametest.ts:83

test? ​

optional test?: ScriptHandle

Defined in: script-host/src/host/gametest.ts:86

The Test object the test function got.

timers ​

timers: Timer[]

Defined in: script-host/src/host/gametest.ts:87


StructurePlacement ​

Defined in: script-host/src/host/gametest.ts:39

Where a test's structure goes: a location, and the dimension when the registration names one.

Properties ​

dimension? ​

readonly optional dimension?: string

Defined in: script-host/src/host/gametest.ts:41

location ​

readonly location: ScriptVector3

Defined in: script-host/src/host/gametest.ts:40

Type Aliases ​

GameTestCall ​

GameTestCall = { ok: true; value: ScriptValue; } | { message: string; ok: false; }

Defined in: script-host/src/host/gametest.ts:94

What calling a pack's callback did.


GameTestState ​

GameTestState = "waiting" | "running" | "done" | "cleaned"

Defined in: script-host/src/host/gametest.ts:69

Where a running test is: waiting for its batch, running, ended, or cleaned up.


Timer ​

Timer = { callback: ScriptHandle; due: number; kind: "callback"; } | { due: number; kind: "idle"; resolve: ScriptHandle; }

Defined in: script-host/src/host/gametest.ts:72

Something due on a later tick of a running test.

Variables ​

BATCH_GAP_TICKS ​

const BATCH_GAP_TICKS: 4 = 4

Defined in: script-host/src/host/gametest.ts:30

The ticks BDS leaves between the end of one batch and the start of the next.


DEFAULT_MAX_TICKS ​

const DEFAULT_MAX_TICKS: 100 = 100

Defined in: script-host/src/host/gametest.ts:33

The ticks a test may run before it fails, when its registration names none.


DEFAULT_TAG ​

const DEFAULT_TAG: "suite:default" = 'suite:default'

Defined in: script-host/src/host/gametest.ts:36

The tag /gametest runset runs when it names none.


GAMETEST ​

const GAMETEST: "@minecraft/server-gametest" = '@minecraft/server-gametest'

Defined in: script-host/src/host/gametest.ts:27

The module the runner's classes belong to.

Functions ​

structurePath() ​

structurePath(structureName): string

Defined in: script-host/src/host/gametest.ts:127

The file of a structure name, as BDS looks it up in a behavior pack.

Parameters ​

structureName ​

string

Returns ​

string