[API reference](https://jsprismarine.dev/api/index.md) / [@jsprismarine/script-host](https://jsprismarine.dev/api/@jsprismarine/script-host/index.md) / [host/gametest](https://jsprismarine.dev/api/@jsprismarine/script-host/host/gametest/index.md) / GameTests

# Class: GameTests\<Owner\>

Defined in: [script-host/src/host/gametest.ts:131](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/script-host/src/host/gametest.ts#L131)

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](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/script-host/src/host/gametest.ts#L144)

#### Parameters

##### host

[`GameTestHost`](https://jsprismarine.dev/api/@jsprismarine/script-host/host/gametest/index.md#gametesthost)\<`Owner`\>

#### Returns

`GameTests`\<`Owner`\>

## Accessors

### currentTick

#### Get Signature

> **get** **currentTick**(): `number`

Defined in: [script-host/src/host/gametest.ts:149](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/script-host/src/host/gametest.ts#L149)

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](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/script-host/src/host/gametest.ts#L276)

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](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/script-host/src/host/gametest.ts#L252)

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

#### Parameters

##### run

[`GameTestRun`](https://jsprismarine.dev/api/@jsprismarine/script-host/host/gametest/index.md#gametestrun)\<`Owner`\>

##### message

`string`

#### Returns

`void`

***

### idle()

> **idle**(`run`, `delay`, `resolve`): `void`

Defined in: [script-host/src/host/gametest.ts:262](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/script-host/src/host/gametest.ts#L262)

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

#### Parameters

##### run

[`GameTestRun`](https://jsprismarine.dev/api/@jsprismarine/script-host/host/gametest/index.md#gametestrun)\<`Owner`\>

##### delay

`number`

##### resolve

[`ScriptHandle`](https://jsprismarine.dev/api/@jsprismarine/script-host/values/classes/ScriptHandle.md)

#### Returns

`void`

***

### options()

> **options**(`registration`): [`GameTestOptions`](https://jsprismarine.dev/api/@jsprismarine/script-host/host/gametest/index.md#gametestoptions) \| `undefined`

Defined in: [script-host/src/host/gametest.ts:172](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/script-host/src/host/gametest.ts#L172)

The options of a registration, which its `RegistrationBuilder` sets.

#### Parameters

##### registration

`number`

#### Returns

[`GameTestOptions`](https://jsprismarine.dev/api/@jsprismarine/script-host/host/gametest/index.md#gametestoptions) \| `undefined`

***

### register()

> **register**(`owner`, `className`, `testName`, `fn`, `async`): `number`

Defined in: [script-host/src/host/gametest.ts:158](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/script-host/src/host/gametest.ts#L158)

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`](https://jsprismarine.dev/api/@jsprismarine/script-host/values/classes/ScriptHandle.md)

##### async

`boolean`

#### Returns

`number`

The registration, which its `RegistrationBuilder` changes.

***

### run()

> **run**(`id`): [`GameTestRun`](https://jsprismarine.dev/api/@jsprismarine/script-host/host/gametest/index.md#gametestrun)\<`Owner`\> \| `undefined`

Defined in: [script-host/src/host/gametest.ts:177](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/script-host/src/host/gametest.ts#L177)

A run, by the id its `Test` object carries.

#### Parameters

##### id

`number`

#### Returns

[`GameTestRun`](https://jsprismarine.dev/api/@jsprismarine/script-host/host/gametest/index.md#gametestrun)\<`Owner`\> \| `undefined`

***

### runAfterDelay()

> **runAfterDelay**(`run`, `delay`, `callback`): `void`

Defined in: [script-host/src/host/gametest.ts:257](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/script-host/src/host/gametest.ts#L257)

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

#### Parameters

##### run

[`GameTestRun`](https://jsprismarine.dev/api/@jsprismarine/script-host/host/gametest/index.md#gametestrun)\<`Owner`\>

##### delay

`number`

##### callback

[`ScriptHandle`](https://jsprismarine.dev/api/@jsprismarine/script-host/values/classes/ScriptHandle.md)

#### Returns

`void`

***

### runOfPlayer()

> **runOfPlayer**(`player`): [`GameTestRun`](https://jsprismarine.dev/api/@jsprismarine/script-host/host/gametest/index.md#gametestrun)\<`Owner`\> \| `undefined`

Defined in: [script-host/src/host/gametest.ts:182](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/script-host/src/host/gametest.ts#L182)

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

#### Parameters

##### player

`string`

#### Returns

[`GameTestRun`](https://jsprismarine.dev/api/@jsprismarine/script-host/host/gametest/index.md#gametestrun)\<`Owner`\> \| `undefined`

***

### runSet()

> **runSet**(`tag?`): [`GameTestReply`](https://jsprismarine.dev/api/@jsprismarine/script-host/host/gametest/index.md#gametestreply)

Defined in: [script-host/src/host/gametest.ts:199](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/script-host/src/host/gametest.ts#L199)

`/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`](https://jsprismarine.dev/api/@jsprismarine/script-host/host/gametest/index.md#gametestreply)

***

### runTest()

> **runTest**(`name`): [`GameTestReply`](https://jsprismarine.dev/api/@jsprismarine/script-host/host/gametest/index.md#gametestreply)

Defined in: [script-host/src/host/gametest.ts:188](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/script-host/src/host/gametest.ts#L188)

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

#### Parameters

##### name

`string`

#### Returns

[`GameTestReply`](https://jsprismarine.dev/api/@jsprismarine/script-host/host/gametest/index.md#gametestreply)

***

### step()

> **step**(`tick`): `void`

Defined in: [script-host/src/host/gametest.ts:222](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/script-host/src/host/gametest.ts#L222)

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`](https://jsprismarine.dev/api/@jsprismarine/script-host/host/gametest/index.md#gametestreply)

Defined in: [script-host/src/host/gametest.ts:209](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/script-host/src/host/gametest.ts#L209)

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

#### Returns

[`GameTestReply`](https://jsprismarine.dev/api/@jsprismarine/script-host/host/gametest/index.md#gametestreply)

***

### succeed()

> **succeed**(`run`): `void`

Defined in: [script-host/src/host/gametest.ts:247](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/script-host/src/host/gametest.ts#L247)

Ends a test as passed.

#### Parameters

##### run

[`GameTestRun`](https://jsprismarine.dev/api/@jsprismarine/script-host/host/gametest/index.md#gametestrun)\<`Owner`\>

#### Returns

`void`

***

### succeedWhen()

> **succeedWhen**(`run`, `condition`): `void`

Defined in: [script-host/src/host/gametest.ts:270](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/script-host/src/host/gametest.ts#L270)

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

#### Parameters

##### run

[`GameTestRun`](https://jsprismarine.dev/api/@jsprismarine/script-host/host/gametest/index.md#gametestrun)\<`Owner`\>

##### condition

[`ScriptHandle`](https://jsprismarine.dev/api/@jsprismarine/script-host/values/classes/ScriptHandle.md)

#### Returns

`void`
