server-core/test-utils
packages/server/src/test-utils
Purpose
Shared server-core test utility exports.Public surface
AppEndpointHandlers
TypeAlias
AnyAppCallbackRpcDefinition union, keyed
by each definition’s wire name. Mandates one handler per
task-callback RPC at construction time — adding a new entry to
appCallbackMethods becomes a compile error at every endpoint
construction site.
AwaitNotificationError
TypeAlias
awaitOneNotification
Function
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.
closeAllClients
Function
connectAppClient
Function
ConnectedAgent
Interface
connectTestClient
Function
CoreSchemaSqlLoadError
TypeAlias
CoreTestDatabasePort
Interface
CoreTestReadyOutcome
TypeAlias
CoreTestRuntimeServerHandle
Interface
CoreTestServer
TypeAlias
CoreTestServerHandle
Interface
CoreTestServerPort
Interface
CoreTestSpan
Interface
CoreTestSpanExporterPort
Interface
createTestAgent
Function
DEFAULT_TEST_ADMIN_USER_ID
Variable
getBaseUrl
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.
makeHandlerAppEndpoint
Function
originator.call dispatches to
in-process handlers instead of going over a WebSocket. The endpoint
satisfies the same { connId, originator } shape a connected app’s
arm carries so AppEndpointRegistry, AppRegistry, and sendRpcToClient see ONE shape.
originator.callback({ definition, params })indexeshandlersbydefinition.name. The mapped type guarantees every member ofAnyAppCallbackRpcDefinitionhas a handler — no runtime “method not found” branch exists.originator.notify/failAllPendingare no-ops.originator.handle/originator.resolvedefect — an in-process endpoint never receives inbound frames; a call here is a wiring bug.
makePgliteHarness
Function
PGLITE_HOOK_TIMEOUT_MS
Variable
PgliteHarness
Interface
PgliteHarnessError
TypeAlias
postJson
Function
body as JSON to ${baseUrl}${path} and resolve with
{status, json}. HTTP integration tests import this helper to avoid
repeated request/JSON boilerplate.
registerAgent
Function
registerAndConnect
Function
registerApp
Function
resetCoreTestDb
Function
setupAgentGroup
Function
setupAgentPair
Function
startCoreTestServer
Function
startCoreTestServerEffect
Function
startCoreTestServerFull
Function
StartCoreTestServerOptions
Interface
stopCoreTestServer
Function
trackClient
Function
Files
app-endpoint.tscore-schema-sql.tsfakes.tshelpers.tsindex.tspglite-harness.tsports.tsserver.ts