Skip to main content
Everything a send does before the network — validation, defaults, serialization, the typed method tree — runs for real under the stub transport, so tests exercise your schema without any HTTP. The compiler is part of the test surface too: wrong payloads, unknown events, and missing fields fail at build time.

The stub transport

stubTransport is exported from the runtime subpath and plugs into the transport option:
The returned result echoes the envelope’s type, customerId, and timestamp with the fixed id msg_stub. Credentials still resolve before the stub runs, so tests exercise the production configuration path; any non-empty key satisfies it.
stubTransport is imported from @repost/client/runtime, not from the package root.

Asserting on the full request

Use the native testing helper to assert on the serialized request and idempotency key. It implements the same one-attempt Transport interface as the production transport:
bodyText, bodyBytes, headers, attempt number, timeout, and idempotency key are captured from the actual runtime attempt.

Deterministic values

Pin the injectable generators to freeze timestamps and generated ids:
With now pinned, the envelope timestamp and every @default(now()) field are fixed.

Testing retry behavior

Queue failures and responses on ScriptedStubTransport, then use deterministicClientOptions() or ManualClock from @repost/client/testing to advance retry delays without sleeping. Set maxAttempts, retryBaseDelayMs, and attemptTimeoutMs on the client; retries never live inside the transport.

Continue

Quickstart

The full setup, from install to first send.

Reliability

The behaviors these seams let you test.

Configuration

The options and transport seams in full.