Multiplayer & Dedicated Server Testing
Automating multiplayer games in Unreal Engine has traditionally been one of game development's hardest challenges. Specter leverages Playwright's multi-context architecture to let you drive a Dedicated Server and multiple game clients simultaneously inside a single test file.
Defining Multi-Client Fixtures with createWorld
In Specter, the default world fixture connects to the authoritative Server (or host PIE instance). Using baseTest.extend() and the createWorld helper, you can spin up additional client connection fixtures:
import { test as baseTest, SpecterWorld } from '@specter-automation/test';
// Extend baseTest: 'world' is the default server, use createWorld for additional clients
export const test = baseTest.extend<{
client1: SpecterWorld;
client2: SpecterWorld;
}>({
client1: async ({ createWorld }, use) => {
const client = await createWorld({
port: 8182,
name: 'Client 1',
autoJoinHost: true,
hostAddress: '127.0.0.1:7777'
});
await use(client);
},
client2: async ({ createWorld }, use) => {
const client = await createWorld({
port: 8183,
name: 'Client 2',
autoJoinHost: true,
hostAddress: '127.0.0.1:7777'
});
await use(client);
},
});Writing Multi-Client Tests
Once defined, inject your multi-client fixtures into your test parameters. Each client instance controls its own PlayerController and UMG viewport independently:
import { test, expect } from './multiplayer-fixtures';
// 'world' is the default server world; client1 & client2 are injected fixtures
test('Player 1 ability damage replicates to Player 2', async ({
world,
client1,
client2
}) => {
// 1. Client 1 (Knight) triggers an ability targeting Player 2
await client1.actor('BP_Hero_Knight').pressKey('Q');
// 2. Assert that Client 2 receives the replicated health reduction on their character
await expect(client2.actor('BP_Hero_Enemy')).toHavePropertyValue('Health', 80);
// 3. Verify server authority ground truth directly on the default server world
await expect(world.actor('BP_Hero_Enemy')).toHavePropertyValue('Health', 80);
});Relevancy, Ownership and Roles
Many “it vanished for the client” bugs aren't about values at all: the server never sent the actor. toBeNetRelevantTo(client)waits for it to reach that client, and when it doesn't, asks the server why: it doesn't replicate, it's only relevant to its owner, the player's view is past its cull distance, or it's dormant.
const chest = world.actor('BP_TreasureChest');
// It reaches client 2 once their player is close enough
await expect(chest).toBeNetRelevantTo(client2);
// Owned by client 1's player, and controlled by them on their machine
const knight = world.actor('BP_Hero_Knight');
await expect(knight).toBeOwnedBy(client1);
await expect(knight.client(client1)).toHaveNetRole('AutonomousProxy');
await expect(knight.client(client2)).toHaveNetRole('SimulatedProxy');
// Or read it all
const info = await chest.getNetInfo({ for: client2 });
// { role: 'Authority', owner: '', onlyRelevantToOwner: false, netCullDistance: 15000,
// relevantTo: false, viewerDistance: 18250, ... }Expected world.actor('BP_TreasureChest') to reach the client within 5000 ms, but it isn't there.
On the server: the player's view is 18250 cm away, past its net cull distance of 15000 cm.Simulating Network Conditions (Ping & Packet Loss)
Don't let your multiplayer game break under high ping or bad connections. Set conditions on one machine, or on every machine with everywhere: true, by profile or by numbers. Each machine delays and drops what it sends, using Unreal's own packet emulation, and everything is reset after the test.
| Profile | Latency (each way) | Jitter | Loss |
|---|---|---|---|
| lan | 2 ms | ±1 ms | 0% |
| good | 20 ms | ±5 ms | 0% |
| average | 45 ms | ±10 ms | 0.5% |
| bad-wifi | 75 ms | ±40 ms | 3% |
| transatlantic | 60 ms | ±8 ms | 0.5% |
| mobile | 120 ms | ±60 ms | 5% |
test('Replication under a bad connection', async ({ world, client1, client2 }) => {
// 1. Every machine on crowded wifi: 75 ms each way, ±40 ms, 3% loss
await world.network.useProfile('bad-wifi', { everywhere: true });
// Or one machine, with your own numbers
await client1.network.setConditions({ latency: 150, jitter: 20, loss: 5 });
// 2. Client 1 triggers an ability targeting Player 2
await client1.actor('BP_Hero_Knight').pressKey('Q');
// 3. The hit lands everywhere, even so
await expect(world.actor('BP_Hero_Enemy')).toHaveReplicatedValue('Health', 80, { timeout: 2000 });
});⚡ Multi-PIE & Standalone Process Support
Specter seamlessly connects to Unreal Engine Play-In-Editor (PIE) with multiple viewports enabled, or to standalone dedicated server and client processes running across separate ports in headless CI/CD builds!
Multiplayer Network Role Tagging
In networked automated tests, understanding which peer executed an action is critical for resolving desyncs. Specter dynamically resolves engine networking state and prefixes all telemetry, logs, and events with the originating network role:
| Prefix | Network Context |
|---|---|
| [Server] | Authoritative dedicated server or listen server host instance. |
| [Client_1], [Client_2] | Specific connected multiplayer client instances in PIE or standalone. |
| [DedicatedServer] | Standalone dedicated server process without local player viewports. |
| [Standalone] | Single-player game session with no networking active. |
Where Network Roles Appear
- Engine Logs (
UE_LOG): Prefixes messages with peer tags (e.g.LogSpecter: [Server] Ability activated...). - WebSocket JSON Payloads: Serialized under
event.networkRolefor test assertions and filtering. - C++ & TypeScript SDK: Stored on
FSpecterTimelineEvent::NetworkRoleandSpecterTimelineEvent.networkRole. - GAS Causality Timelines: Displayed alongside timestamps (e.g.
• 🎯 [Server] [1.02s] Ability Activated).
// WebSocket JSON Event Packet with Network Role Tagging:
{
"type": "GLOBAL_timeline-event",
"networkRole": "Server",
"timestamp": 1.45,
"eventName": "GameplayEffectApplied",
"target": "BP_Hero_Knight",
"instigator": "BP_Hero_Gunner",
"effect": "GE_Gunner_BasicAttack"
}