Skip to content

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

Class: GameTests<Owner> ​

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

The runner of one world's GameTests.

Type Parameters ​

Owner ​

Owner

Constructors ​

Constructor ​

new GameTests<Owner>(host): GameTests<Owner>

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

Parameters ​

host ​

GameTestHost<Owner>

Returns ​

GameTests<Owner>

Accessors ​

currentTick ​

Get Signature ​

get currentTick(): number

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

The tick of the runner's last step, which a test's delays count from.

Returns ​

number

Methods ​

clear() ​

clear(): void

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

Frees every handle a pack gave the runner, for a reload or a shutdown.

Returns ​

void


fail() ​

fail(run, message): void

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

Ends a test as failed, with the reason the log gives.

Parameters ​

run ​

GameTestRun<Owner>

message ​

string

Returns ​

void


idle() ​

idle(run, delay, resolve): void

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

Resolves a promise once a number of ticks of the test have passed.

Parameters ​

run ​

GameTestRun<Owner>

delay ​

number

resolve ​

ScriptHandle

Returns ​

void


options() ​

options(registration): GameTestOptions | undefined

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

The options of a registration, which its RegistrationBuilder sets.

Parameters ​

registration ​

number

Returns ​

GameTestOptions | undefined


register() ​

register(owner, className, testName, fn, async): number

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

Registers a test, as register and registerAsync do. A test registered twice under one name replaces the first.

Parameters ​

owner ​

Owner

className ​

string

testName ​

string

fn ​

ScriptHandle

async ​

boolean

Returns ​

number

The registration, which its RegistrationBuilder changes.


run() ​

run(id): GameTestRun<Owner> | undefined

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

A run, by the id its Test object carries.

Parameters ​

id ​

number

Returns ​

GameTestRun<Owner> | undefined


runAfterDelay() ​

runAfterDelay(run, delay, callback): void

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

Runs a callback once a number of ticks of the test have passed.

Parameters ​

run ​

GameTestRun<Owner>

delay ​

number

callback ​

ScriptHandle

Returns ​

void


runOfPlayer() ​

runOfPlayer(player): GameTestRun<Owner> | undefined

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

The run that spawned a simulated player, whose structure its test-relative locations count from.

Parameters ​

player ​

string

Returns ​

GameTestRun<Owner> | undefined


runSet() ​

runSet(tag?): GameTestReply

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

/gametest runset [tag]: queues every test that has the tag, or whose class is named by it, as BDS's runset jsp ran every test of class jsp.

Parameters ​

tag? ​

string = DEFAULT_TAG

Returns ​

GameTestReply


runTest() ​

runTest(name): GameTestReply

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

/gametest run <name>: queues one test in a batch of its own.

Parameters ​

name ​

string

Returns ​

GameTestReply


step() ​

step(tick): void

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

One step of the runner, at the start of a script flush: cleans up the tests that ended before it, fails the ones out of ticks, runs what is due, and starts the next batch.

Parameters ​

tick ​

number

system.currentTick of the flush.

Returns ​

void


stopAll() ​

stopAll(): GameTestReply

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

/gametest stopall and clearall: ends every test that has not ended, and drops the queued ones.

Returns ​

GameTestReply


succeed() ​

succeed(run): void

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

Ends a test as passed.

Parameters ​

run ​

GameTestRun<Owner>

Returns ​

void


succeedWhen() ​

succeedWhen(run, condition): void

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

Checks a condition now and once each tick after: the first time it returns without throwing, the test passes.

Parameters ​

run ​

GameTestRun<Owner>

condition ​

ScriptHandle

Returns ​

void