# Variable: testing (/pixi-vn/index/namespaces/Game/variables/testing)



\> `const` **testing**: `object`

Defined in: [src/index.ts:555](https://github.com/DRincs-Productions/pixi-vn/blob/5bb5bb1f92e38998ea2f477b600168d8da3ece19/src/index.ts#L555)

Lets an AI agent (or any external script/browser console) drive and inspect a running game
through `window`, without needing to know the app's own UI wiring. Not enabled by default —
something must opt in, typically only in development. Two pieces are needed:

* `enable()`/`disable()` turn the `window` bridge on/off — the `@drincs/pixi-vn/vite` plugin's
  `testing` option does this automatically while its dev server is running, with no extra code.
* `setProps(props)` keeps the live app props (`navigate`/`t`/`toast`/etc.) available to every
  action — call it unconditionally from wherever your app builds those props (e.g. at the end
  of a `useGameProps()`-style hook), since every action needs up-to-date props whether or not
  testing happens to be enabled right now.
* `setActions(actions)` is optional: if the app wraps `narration`/`stepHistory` in its own
  functions to handle UI-only concerns (a loading indicator, blocking while a menu is open,
  refreshing cached interface data, ...), it can register those functions so `continue()`,
  `goBack()`, `selectChoice()`, `start()`, `jump()` and `call()` drive the game through them
  instead of calling `narration`/`stepHistory` directly — same as a real player action would.
  See the `pixi-vn-testing` skill for the full guide (activation patterns, the complete command
  surface, and cookbook snippets for a browser-driven test session).

## Type Declaration [#type-declaration]

### disable [#disable]

\> **disable**: () => `void`

Disables a session started with `enable`: removes the error handler and, if it's
still the current value, deletes `window[windowKey]`. No-op if testing isn't enabled.

#### Returns [#returns]

`void`

### enable [#enable]

\> **enable**: \<`T`>(`options?`) => [`GameTestingAPI`](/pixi-vn/index/interfaces/GameTestingAPI)\<*typeof* [`Game`](/pixi-vn/index/namespaces/Game), `T`>

Enables the testing API: builds it, attaches it to `window[windowKey]` (default
`"pixiVN"`), and returns it. Calling this again replaces the previous session.

#### Type Parameters [#type-parameters]

##### T [#t]

`T` *extends* `object` = \{ }

#### Parameters [#parameters]

##### options? [#options]

###### windowKey? [#windowkey]

`string`

The property name to attach the API under on `window`.

#### Returns [#returns-1]

[`GameTestingAPI`](/pixi-vn/index/interfaces/GameTestingAPI)\<*typeof* [`Game`](/pixi-vn/index/namespaces/Game), `T`>

#### Default [#default]

```ts
"pixiVN"
```

### isEnabled [#isenabled]

\> **isEnabled**: () => `boolean`

Whether a testing session is currently active.

#### Returns [#returns-2]

`boolean`

### setActions [#setactions]

\> **setActions**: \<`T`>(`actions`) => `void`

Registers the app's own narration functions so [GameTestingAPI](/pixi-vn/index/interfaces/GameTestingAPI)'s `continue`,
`goBack`, `selectChoice`, `start`, `jump` and `call` call them instead of going straight to
`narration`/`stepHistory` — useful when the app wraps those with UI-only concerns (e.g. a
loading indicator, blocking while a menu is open, refreshing cached interface data) that a
test session driving the game through `window` should also go through, exactly like a real
player action would. Safe to call whether or not testing is currently `enable`d, and
safe to call again to update the registered functions (e.g. when they close over fresh
props). Persists across `disable`/`enable`, same as `setProps`.

#### Type Parameters [#type-parameters-1]

##### T [#t-1]

`T` *extends* `object` = \{ }

#### Parameters [#parameters-1]

##### actions [#actions]

[`GameTestingActions`](/pixi-vn/index/interfaces/GameTestingActions)\<`T`>

The app's own narration functions to use in place of the defaults. Pass `{}`
(or omit an action) to keep/restore the default behavior for that action.

#### Returns [#returns-3]

`void`

### setProps [#setprops]

\> **setProps**: \<`T`>(`props`) => `void`

Updates the live props every [GameTestingAPI](/pixi-vn/index/interfaces/GameTestingAPI) action merges `extraProps` on top of.
Call this unconditionally from wherever your app builds its `StepLabelProps` (e.g. the end
of a `useGameProps()`-style hook that already runs throughout the app) — it's a cheap
assignment, safe to call whether or not testing is currently `enable`d.

#### Type Parameters [#type-parameters-2]

##### T [#t-2]

`T` *extends* `object` = \{ }

#### Parameters [#parameters-2]

##### props [#props]

[`StepLabelPropsType`](/pixi-vn/index/type-aliases/StepLabelPropsType)\<`T`>

The app's current `StepLabelProps` (the same object your UI passes to
`narration.continue`/`Game.start`).

#### Returns [#returns-4]

`void`
