server-core/test-utils
packages/server/src/test-utils
Purpose
Shared server-core test utility exports.Public surface
AwaitNotificationError
TypeAlias
awaitOneNotification
Function
client.subscribeTo(def) via
Stream.runHead, failing with a tagged error on timeout or stream
exhaustion. Replaces the deleted client.waitForNotification(def) shape
at integration-test call sites; preserves the yield* … ergonomic but
runs entirely on the new Stream.async-backed subscription API.
closeAllClients
Function
ConnectedAgent
Interface
connectTestClient
Function
CoreSchemaSqlLoadError
TypeAlias
CoreTestRuntimeServerHandle
Interface
CoreTestServer
Interface
expectRpcFailure
Function
RpcServerError(code) and returns the
narrowed error for follow-up assertions. catchTags routes by tag name
declaratively so callers never reach for err._tag.
getBaseUrl
Function
getCoreApp
Function
getCoreDb
Function
getCoreEncryptionEnvelope
Function
getWsUrl
Function
loadCoreSchemaSql
Function
makeFakeService
Function
S from a partial implementation.
The cast is intentional: tests typically implement only the methods the
system under test actually calls. Unused methods throw at runtime via the
Proxy trap so a missing implementation becomes a clear test failure
instead of undefined is not a function.
Because the generic parameter S is invariant, TypeScript still enforces
that every method you do implement matches the real signature — this is
the compile-time contract-drift insurance. Adding a field to the real
interface does NOT fail compilation (tests are a Partial), but changing an
existing field’s signature does.
makePgliteHarness
Function
PGLITE_HOOK_TIMEOUT_MS
Variable
PgliteHarness
Interface
PgliteHarnessError
TypeAlias
postJson
Function
body as JSON to ${baseUrl}${path} and resolve with
{status, json}. The endpoints under test (/api/v1/auth/register,
/api/v1/auth/claim, /api/v1/admin/register-agent) all use this
same wire envelope, so each integration test importing this helper
can drop the repeated request/JSON boilerplate.
registerAgent
Function
registerAndConnect
Function
registerOnly
Function
resetCoreTestDb
Function
ServerTestClient
Interface
waitForNotification(def, timeoutMs?),
drainNotifications(): ReadonlyArray<...>, and notifications Stream
wrappers were deleted. Consumers reach typed-payload Streams via
client.subscribeTo(def) (a one-line passthrough to
TestClient.subscribe(def)) or the broad-union client.subscribeAll().
Ergonomic one-shot test sites use the top-level awaitOneNotification
helper below.
setupAgentGroup
Function
setupAgentPair
Function
startCoreTestServer
Function
stopCoreTestServer
Function
trackClient
Function
Files
core-schema-sql.tsfakes.tshelpers.tspglite-harness.tsrpc-error.tsserver.ts