Skip to main content

server-core/test-utils

packages/server/src/test-utils

Purpose

Shared server-core test utility exports.

Public surface

AwaitNotificationError

TypeAlias
Represents await notification error conditions.

awaitOneNotification

Function
Stream-based one-shot waiter. Consumes client.subscribe(def) via Stream.runHead, failing with AwaitNotificationTimeoutError on timeout and AwaitNotificationClosedError when the transport closed before a matching frame arrived. Distinguishing close from timeout keeps a dead connection from masquerading as a missing notification. Returns: The await one notification result.

closeAllClients

Function
Executes the close all clients operation. Returns: The close all clients result.

ConnectedAgent

Interface
Describes connected agent.

connectTestClient

Function
Executes the connect test client operation. Returns: The connect test client result.

CoreSchemaSqlLoadError

TypeAlias
Represents core schema sql load error conditions.

CoreTestDatabasePort

Interface
Database operations available to consumers of the published test harness.

CoreTestReadyOutcome

TypeAlias
Represents core test ready outcome values.

CoreTestRuntimeServerHandle

Interface
Process capabilities needed by in-process runtime tests.

CoreTestServer

TypeAlias
Canonical published handle for a running core test server.

CoreTestServerHandle

Interface
Describes core test server handle.

CoreTestServerPort

Interface
Published server handle composed only from server-owned test ports.

CoreTestSpan

Interface
Stable projection of a finished server trace span.

CoreTestSpanExporterPort

Interface
Trace-capture operations available to test-harness consumers.

createTestAgent

Function
Creates test agent. Returns: The created test agent.

DEFAULT_TEST_ADMIN_USER_ID

Variable
Validates and decodes default test admin user id values.

getBaseUrl

Function
Returns base url. Returns: The get base url result.

getCoreDb

Function
Returns core db. Returns: The get core db result.

getWsUrl

Function
Returns ws url. Returns: The get ws url result.

loadCoreSchemaSql

Function
Loads core schema sql. Returns: The load core schema sql result.

makePgliteHarness

Function
Spin up a fresh PGlite instance with the core schema loaded. Returns: The created pglite harness.

PGLITE_HOOK_TIMEOUT_MS

Variable
Suggested timeout for pglite-backed beforeEach/afterEach hooks.

PgliteHarness

Interface
Describes pglite harness.

PgliteHarnessError

TypeAlias
Represents pglite harness error conditions.

postJson

Function
POST body as JSON to ${baseUrl}${path} and resolve with {status, json}. HTTP integration tests import this helper to avoid repeated request/JSON boilerplate. Returns: The post json result.

registerAgent

Function
Registers agent. Returns: The register agent result.

registerAndConnect

Function
Register and connect an agent. Tracked for automatic cleanup. Returns: The register and connect result.

resetCoreTestDb

Function
Executes the reset core test db operation. Returns: The reset core test db result.

setupAgentGroup

Function
Create N agents, all connected. Optionally create a group conversation. Returns: The setup agent group result.

setupAgentPair

Function
Create two agents, both connected. Returns: The setup agent pair result.

startCoreTestServer

Function
Start a test server and expose its package-owned integration ports. Returns: A promise for the running server’s integration ports.

startCoreTestServerEffect

Variable
Executes the start core test server effect operation.

startCoreTestServerFull

Function
Executes the start core test server full operation. Returns: The start core test server full result.

StartCoreTestServerOptions

Interface
Configures start core test server.

stopCoreTestServer

Function
Executes the stop core test server operation. Returns: The stop core test server result.

trackClient

Function
Executes the track client operation.

Files

  • core-schema-sql.ts
  • helpers.ts
  • index.ts
  • pglite-harness.ts
  • ports.ts
  • server.ts