Skip to content

Connectum API Reference / @connectum/testing / index / createTestServer

Function: createTestServer() ​

createTestServer(options): Promise<TestServer>

Defined in: testing/src/test-server.ts:53

Create and start a test server on a random (or specified) port.

Returns a TestServer with a pre-configured gRPC transport ready for use with ConnectRPC clients. The caller is responsible for calling TestServer.close when done.

The server listens on 127.0.0.1 unless options.host says otherwise. TestServer.close waits up to options.shutdown.timeout (30 s by default) for calls that have not finished.

Parameters ​

options ​

CreateTestServerOptions

Server configuration (services, interceptors, protocols, port, host, shutdown)

Returns ​

Promise<TestServer>

Running test server with transport and cleanup function

Example ​

typescript
const server = await createTestServer({ services: [myRoutes] });
const client = createClient(MyService, server.transport);
const response = await client.myMethod({ id: "1" });
await server.close();