Skip to main content

Test Runner API

test(name, options?, fn)

Defines an individual test case.
string
required
The title/description of the test.
number
Runs N independent instances of the test simultaneously with distinct leased accounts to detect race conditions.
Partial<EnvironmentCapabilities>
Environment capabilities required for this test to execute.
string[]
List of environment names where this test is allowed to run.

describe.serial(name, options?, fn)

Groups tests that execute sequentially while retaining the same player/bot session and leased account across all tests in the block.
string
required
The title/description of the serial block.
string
Specific account name to lease from the environment’s account pool.
number
Runs N independent copies of the entire ordered serial chain at the same time.

afterAll(fn)

Registers a hook that runs once per instance of the enclosing describe.serial block, after its last executed test — whether the block finished all its tests, stopped early on a failure, or a test in it was skipped. Only valid inside describe.serial. Not called if the block never got its player (the initial connect failed). A throwing hook is logged, not fatal.
(ctx: TestContext) => Promise<void> | void
required
The cleanup hook.

player / bot Object

The player or bot object represents a real Minecraft client connected to the test server.

Methods

player.chat(message)

Sends a chat message or command.
string
required
The message or command to send.

player.gui(options)

Waits for a GUI to open matching the title and returns a live handle.
string | RegExp
required
Pattern to match GUI title.

player.makeOp()

Grants operator status to the player.

player.deOp()

Removes operator status from the player.

player.setGameMode(mode)

Changes the player’s game mode.
string
required
‘survival’ | ‘creative’ | ‘adventure’ | ‘spectator’

player.teleport(x, y, z)

Teleports the player to coordinates.

player.giveItem(item, count?)

Gives items to the player.

player.clearInventory(item?, options?)

Clears the player’s inventory and waits until the client-side inventory state reflects it. If an item name is specified, only that item is cleared.

Properties

Inventory
Access the player’s current inventory state.
string
The randomly generated or assigned name of the bot.

server Object

The server object gives you control over the backend Minecraft server.

Methods

server.execute(command)

Executes a command from the server console.
string
required
The console command to execute.

Exported Utilities

The Plugwright framework exports several utility functions to help you write robust tests.

createPlayer()

Creates a new, independent player bot that joins the server. Useful for multi-user tests.
string
Connect as this exact name instead of taking whatever the environment’s account pool has free.
string
Names the bot inside a describe.serial block, so a later test in that block gets the same bot back instead of connecting another one.
string
The password an authentication plugin logs username in with. Only for a named bot: a pool account already carries its own, and passing both is an error.
Ask for a name only when the test needs that specific identity — an account somebody provisioned by hand, or a name that came out of an external API. A second bot that is only there to be a second player should stay unnamed, so a stand can lease it from the pool.
Read the password from the environment. Spec files go to git.

sleep(ms)

Pauses execution for a specified number of milliseconds.
number
required
Milliseconds to sleep.

poll(fn, options?)

Repeatedly executes a function until it returns a value that is not undefined, and returns that value. Useful when you are waiting for an object or value to exist and need to extract it.
function
required
Function to poll.
number
Max wait time in ms (default: 5000ms).
number
Check interval in ms (default: 100ms).

waitForAssertion(fn, options?)

Executes an assertion function repeatedly until it passes or times out. Ideal for expect statements.
function
required
Assertion function.

waitUntil(predicate, options?)

Repeatedly executes a boolean function until it returns true. Useful when you simply want to pause execution until a condition is met, without extracting any data.

waitForStable(fn, options?)

Waits for a value returned by a function to remain unchanged for a specified duration. Useful for waiting for a UI to finish animating or loading.
function
required
Function to evaluate.
number
Time the value must remain stable in ms (default: 500ms).