Multiplayer tests
Add fake players to a test world, or send an action from a real client to a dedicated server and check both sides.
Some features only make sense with more than one player, like sending a gift to a friend or sharing a party's rewards. TeaKit gives you two ways to test them. Fake players join the world your test is already using, without a second client. A paired test runs a real client against a dedicated server.
Add another player
player.fake.spawn adds a server-side player to the world. It appears in the player list, commands and selectors can target it, and server-side player behavior applies to it as it would to anyone else. It has no client, so it can't open screens or press keys.
Suppose your mod has an examplemod gift <player> command that sends one diamond to another player. This test spawns the other player and checks that the gift arrives:
import { Capability, Readiness, expect, pos, test } from "@teakit/test";
test("a gift reaches the other player", {
capabilities: [Capability.PlayerFake, Capability.ServerCommands],
readiness: [Readiness.World, Readiness.Player],
target: { minecraft: ">=1.21.11" },
}, async ({ player, world, commands, server }) => {
const origin = pos(0, 100, 0);
await world.fill(origin.offset(-2, -1, -2), origin.offset(2, -1, 2), "minecraft:stone");
await world.clear(origin.offset(-2, 0, -2), origin.offset(2, 3, 2));
await player.teleport({ x: 0.5, y: 100, z: 0.5 });
const friend = await player.fake.spawn("Alex", origin.offset(1, 0, 0));
await commands.run(`examplemod gift ${friend.name}`);
await expect(async () => (await server.command(`clear ${friend.name} minecraft:diamond 0`)).result)
.toEventuallyEqual(1, { timeout: "5s" });
});Give the fake player a floor and headroom where it spawns. TeaKit removes the fake players a test created when that test ends. player.fake.remove(name) removes one sooner, and player.fake.list() shows the ones still in the world. Fake players don't leave player files in the world or change Minecraft's saved list of player names.
Each fake player gets its own UUID. To make one look like a real player, pass skinFrom with a Minecraft username:
const friend = await player.fake.spawn("Alex", origin.offset(1, 0, 0), { skinFrom: "iamkaf" });It copies that account's skin and keeps the fake player's own UUID. If the skin can't be fetched, the fake player uses a default skin.
The player helpers still act on your own player, and player.self() returns it. To give a fake player items, pass it to a world transaction:
await world.transaction("gift-setup").give(friend, "minecraft:apple", { count: 2 }).run();Fake players need Minecraft 1.21.11 or newer. In a paired test, they join the dedicated server.
Test against a dedicated server
A singleplayer test can miss a feature that only works because client and server share a process. Run a paired test when you need to check a dedicated server: one TeaKit test drives a client and observes the server it has joined.
A useful multiplayer test follows the whole action. Send the request from the client, check the server's result, then check that the client received the update.


Prepare two development runs
Install your mod and TeaKit's runtime in both the development client and dedicated server. Give them separate game directories, such as run-client and run-server, so their saves, logs, and TeaKit connection files stay separate.
Use your loader's development run configurations to start both processes. The client can remain at the title screen; wait until the server has finished starting. Each running instance writes a teakit/instance.json file inside its own game directory.
Both runs must use the Minecraft version and loader of the node you select. When configuring these runs yourself, supply their matching teakit.minecraftVersion and teakit.loader JVM properties so TeaKit can identify them. The launch configuration guide explains node names and development launch settings.
Keep these connection files local. They contain credentials for controlling that game instance and should not be committed or attached to a bug report.
Connect the pair
Choose the node from ./teakitw nodes, then run:
./teakitw pair \
--node "$TEAKIT_NODE" \
--client-instance run-client/teakit/instance.json \
--server-instance run-server/teakit/instance.json \
--server-address 127.0.0.1:25565 \
--test-file test/teakit/reward.test.tsSet TEAKIT_NODE to the selected node name before running this command. Adjust the game directories and server address to match your development runs.
This command uses the two running instances. It connects the client to the given server and waits for the server to see a player before starting the test. Both games keep running after the test finishes, so you can run another test file against the same pair. Stop them yourself when you're done.
Follow a reward from request to result
Suppose your mod has an examplemod reward command that grants the calling player one diamond. The test below clears the inventory first, sends the command from the client, and checks both sides of the result. Replace the command and reward with your own feature.
import { expect, test } from "@teakit/test";
test("the reward reaches the requesting player", async ({
session, player, client, server, artifacts,
}) => {
expect((await session.info()).paired).toBe(true);
await player.reset({ gameMode: "survival", inventory: "clear" });
await client.closeMenus();
await client.command("examplemod reward");
await expect(async () => {
const count = await server.command("clear @a minecraft:diamond 0");
return count.result;
}).toEventuallyEqual(1, { timeout: "5s" });
await client.openInventory();
await expect(async () => {
const screen = await client.screen();
return screen.menu().slots().some(
(slot) => slot.item?.itemId === "minecraft:diamond",
);
}).toEventuallyEqual(true, { timeout: "5s" });
await artifacts.attachScreenshot(await client.screenshot("received-reward"));
await client.closeMenus();
});clear @a minecraft:diamond 0 counts matching items on the server without removing any. With one player and an initially empty inventory, the expected count is exactly one. client.screen() reads the client's open menu. Checking both distinguishes “the server never granted the reward” from “the server granted it, but the client did not receive it.”
client.command() travels through the player's client command path. Calling server.command() instead would run from the server console and would not exercise the player's request. Use server commands for setup when appropriate, then perform the action under test through the client.
@a works here because the client's player is the only one on the server. The player helpers always act on the client's player. If the test also adds fake players, select players by name in server commands.
Know which side you are reading
In a paired test, client and render inspect the client, while world and server operate on the dedicated server. Use server.command() for a server-side inventory check as shown above; use the client menu to inspect what the player sees.
player actions go through the client the way a real player's would: reading the inventory, selecting a hotbar slot, using items, looking, placing blocks, using blocks and entities, and travel. Setup helpers such as player.reset, player.give, and player.teleport act on the dedicated server.
To check whether an optional integration is installed on a particular side, call runtime.mods.isLoaded("othermod", { side: "client" }) or use side: "server". A client-only integration may be absent from the server without anything being wrong.
Use session.client.health() and session.server.health() when a failure depends on whether one side finished connecting. Attach only the fields needed to explain the failure, rather than the complete connection metadata.
Read a failed pair run
The pair command writes its report under build/teakit/<node>/<test-file>.pair/summary.json. Start with the failed assertion, then look at the attachments and each game's log.
If the command never reaches your test, check that both connection files belong to currently running instances and that the server address is reachable from the client. If server state changes but the menu assertion times out, investigate the update sent back to the client.
See Diagnosing failures for attaching the state that explains a failure without hiding the original assertion.