Skip to content

@insler/rpc/host/test

The default integration seam for services built on this stack: TestHost.pair(contract, handlers) gives you a real contract, real host validation, and a real typed client over an in-memory bus — no external dependencies, no mocks of your own code.

import { TestHost } from '@insler/rpc/host/test';
const { client, host } = await TestHost.pair(Accounts, handlers);
await client.getBalance({ accountId: 'a_1' }); // validated end to end
await host.stop();
  • TestHost.pair(contract, handlers) — a throw-mode client + host pair.
  • TestHost.resultPair(contract, handlers) — the result-mode variant, for asserting typed errors as { ok: false, error } values.

Write integration tests here unless the test is specifically about wire behavior. Everything a consumer observes — validation failures, typed errors, context extraction, streaming — behaves exactly as it does over a real transport, because it is the real client and host wired over @insler/rpc/transport-memory. For client-only logic use the cheaper TestTransport; for wire-format, serde, or queue-group behavior test against the NATS adapter and a real server.