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);
});

Replication & Server Authority

toHaveReplicatedValue checks every machine in the test at once: the server and each client you connected with createWorld. It waits until they all have the value, so it works under lag, and when one doesn't, the failure shows what each machine has and how long each took to get it.

test('Charge damage reaches every player', async ({ world, client1, client2 }) => {
  const enemy = world.actor('BP_Hero_Enemy');
  await client1.actor('BP_Hero_Knight').pressKey('Q');

  // The server and both clients agree, within half a second
  await expect(enemy).toHaveReplicatedValue('Health', 80, { timeout: 500 });

  // An attribute, or anything you can read from each machine's copy
  await expect(enemy).toHaveReplicatedValue({ attribute: ['HealthSet', 'Health'] }, 80);
  await expect(enemy).toHaveReplicatedValue(actor => actor.hasGameplayTag('Status.Stunned'), true);

  // No value: every machine agrees with the server, whatever it is
  await expect(world.actor('BP_ScoreBoard')).toHaveReplicatedValue('RedScore');
});
Expected Health = 80 on every machine within 500 ms, but 1 of 3 didn't have it:
  server (server)    80           ✓
  client1 (client)   80           ✓ after 120 ms
  client2 (client)   100          ✗
  • The locator you call it on is the reference: usually the server's (world.actor(...)). Each client gets the same locator through .client(clientWorld).
  • Numbers count as equal within tolerance (default 0.01). Structs and arrays compare by value.
  • Compare values, not object references: a client's copy of an actor can have a different name.

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.

ProfileLatency (each way)JitterLoss
lan2 ms±1 ms0%
good20 ms±5 ms0%
average45 ms±10 ms0.5%
bad-wifi75 ms±40 ms3%
transatlantic60 ms±8 ms0.5%
mobile120 ms±60 ms5%
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:

PrefixNetwork 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.networkRole for test assertions and filtering.
  • C++ & TypeScript SDK: Stored on FSpecterTimelineEvent::NetworkRole and SpecterTimelineEvent.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"
}