Skip to content

@connectum/test-fixtures

Lightweight mock factories, assertion helpers, and protobuf descriptor fixtures shared across the @connectum/* test suites.

Layer: 2 (Testing Utilities)

This package is transport-free — it does not depend on @connectum/core, @connectum/interceptors, or any other Connectum package. That keeps the workspace dependency graph acyclic and lets every Connectum package depend on it without build cycles.

Related

  • @connectum/testing -- higher-level test server, in-process transport, OTel collectors, parity driver (re-exports everything here)
  • Testing -- testing strategies and tools

Full API Reference

Complete TypeScript API documentation: API Reference

Installation

bash
pnpm add -D @connectum/test-fixtures

Requires: Node.js 22.13+

Peer dependencies: @connectrpc/connect, @bufbuild/protobuf

Most consumers do not install this directly — @connectum/testing re-exports every symbol from it, so importing from @connectum/testing continues to work unchanged.

What lives here

ExportPurpose
assertConnectErrorAssertion helper for thrown ConnectError values (code + message).
createMockFnPortable, node:test-free spy factory (works under Bun/esbuild).
createMockRequestFake unary ConnectRPC request.
createMockNext, createMockNextError, createMockNextSlowFake next handlers for interceptor tests.
createMockStreamAsync iterable for streaming tests.
createMockDescMessage, createMockDescField, createMockDescMethodProtobuf descriptor mocks.
createFakeService, createFakeMethodGeneric DescService / DescMethod fixtures.

Example

ts
import { assertConnectError, createMockRequest } from "@connectum/test-fixtures";
import { Code, ConnectError } from "@connectrpc/connect";

assertConnectError(
    new ConnectError("not found", Code.NotFound),
    Code.NotFound,
    "not found",
);