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

# host/gametest

## Classes

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

## Interfaces

### GameTestHost

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

What the runner reaches of the runtime that owns it.

#### Type Parameters

##### Owner

`Owner`

#### Properties

##### log

> `readonly` **log**: [`ScriptLog`](https://jsprismarine.dev/api/@jsprismarine/script-host/host/WorldScripts/index.md#scriptlog)

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

##### world

> `readonly` **world**: [`ScriptWorld`](https://jsprismarine.dev/api/@jsprismarine/script-host/host/world/index.md#scriptworld)

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

#### Methods

##### call()

> **call**(`owner`, `callback`, `args`): [`GameTestCall`](#gametestcall)

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

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

###### args

readonly [`ScriptValue`](https://jsprismarine.dev/api/@jsprismarine/script-host/values/index.md#scriptvalue)[]

###### Returns

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

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

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

###### Parameters

###### owner

`Owner`

###### run

`number`

###### Returns

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

##### free()

> **free**(`handle`): `void`

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

###### Parameters

###### handle

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

###### Returns

`void`

##### onRejected()

> **onRejected**(`owner`, `promise`, `rejected`): `void`

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

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

###### rejected

(`message`) => `void`

###### Returns

`void`

##### structure()

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

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

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

What a `RegistrationBuilder` sets on a test.

#### Properties

##### batch?

> `optional` **batch?**: `string`

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

##### maxTicks

> **maxTicks**: `number`

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

##### required

> **required**: `boolean`

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

##### setupTicks

> **setupTicks**: `number`

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

Ticks between placing the structure and calling the test function.

##### structureLocation?

> `optional` **structureLocation?**: [`StructurePlacement`](#structureplacement)

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

##### structureName

> **structureName**: `string`

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

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

***

### GameTestRegistration

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

One registered test.

#### Type Parameters

##### Owner

`Owner`

#### Properties

##### async

> `readonly` **async**: `boolean`

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

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

##### fn

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

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

##### name

> `readonly` **name**: `string`

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

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

##### options

> `readonly` **options**: [`GameTestOptions`](#gametestoptions)

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

##### owner

> `readonly` **owner**: `Owner`

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

***

### GameTestReply

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

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

#### Properties

##### message

> `readonly` **message**: `string`

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

##### ok

> `readonly` **ok**: `boolean`

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

***

### GameTestRun

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

One run of a test.

#### Type Parameters

##### Owner

`Owner`

#### Properties

##### conditions

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

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

##### dimension

> `readonly` **dimension**: `string`

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

##### id

> `readonly` **id**: `number`

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

##### origin

> `readonly` **origin**: [`ScriptVector3`](https://jsprismarine.dev/api/@jsprismarine/script-host/host/world/index.md#scriptvector3)

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

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

The simulated players the test spawned and has not removed.

##### registration

> `readonly` **registration**: [`GameTestRegistration`](#gametestregistration)\<`Owner`\>

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

##### startTick

> **startTick**: `number`

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

##### state

> **state**: [`GameTestState`](#gameteststate)

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

##### test?

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

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

The `Test` object the test function got.

##### timers

> **timers**: [`Timer`](#timer)[]

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

***

### StructurePlacement

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

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

##### location

> `readonly` **location**: [`ScriptVector3`](https://jsprismarine.dev/api/@jsprismarine/script-host/host/world/index.md#scriptvector3)

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

## Type Aliases

### GameTestCall

> **GameTestCall** = \{ `ok`: `true`; `value`: [`ScriptValue`](https://jsprismarine.dev/api/@jsprismarine/script-host/values/index.md#scriptvalue); \} \| \{ `message`: `string`; `ok`: `false`; \}

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

What calling a pack's callback did.

***

### GameTestState

> **GameTestState** = `"waiting"` \| `"running"` \| `"done"` \| `"cleaned"`

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

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

***

### Timer

> **Timer** = \{ `callback`: [`ScriptHandle`](https://jsprismarine.dev/api/@jsprismarine/script-host/values/classes/ScriptHandle.md); `due`: `number`; `kind`: `"callback"`; \} \| \{ `due`: `number`; `kind`: `"idle"`; `resolve`: [`ScriptHandle`](https://jsprismarine.dev/api/@jsprismarine/script-host/values/classes/ScriptHandle.md); \}

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

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

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

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

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

The module the runner's classes belong to.

## Functions

### structurePath()

> **structurePath**(`structureName`): `string`

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

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

#### Parameters

##### structureName

`string`

#### Returns

`string`
