/** * Test harness: createTestRouter and wrapTestRouter implementations. * Provides a clean, ergonomic testing API for WS-Kit routers. */ import type { ConnectionData } from "../context/base-context.js"; import type { Router } from "../core/router.js"; import { type Clock } from "./fake-clock.js"; import type { TestRouter } from "./types.js"; /** * Test harness options. */ export interface CreateTestRouterOptions { /** * Router factory (default: createRouter with no options). */ create?: () => Router; /** * Plugins to apply after creating the router. */ plugins?: ((router: Router) => Router)[]; /** * Clock implementation (default: FakeClock for determinism). */ clock?: Clock; /** * Enable automatic error capture via onError (default: true). */ onErrorCapture?: boolean; /** * Capture pub/sub publishes (if pub/sub is enabled). * This automatically taps into the pub/sub observer to capture publish records. * Default: true. */ capturePubSub?: boolean; /** * Strict mode: fail on timer leaks instead of warn (default: false). * Useful in CI to catch unclosed RPCs and other timer-based bugs. */ strict?: boolean; } /** * Create a test router for convenient testing. * * Example: * ```ts * const tr = createTestRouter({ * create: () => createRouter().plugin(withZod()), * }); * * const conn = tr.connect({ data: { userId: "u1" } }); * conn.send("PING", { text: "hello" }); * await tr.flush(); * expect(conn.outgoing()).toContainEqual({ type: "PONG", ... }); * ``` */ export declare function createTestRouter(opts?: CreateTestRouterOptions): TestRouter; /** * Wrap an existing router with test infrastructure. * Useful for testing production routers in black-box mode. */ export declare function wrapTestRouter(router: Router, opts?: { clock?: Clock; onErrorCapture?: boolean; capturePubSub?: boolean; strict?: boolean; }): TestRouter; //# sourceMappingURL=test-harness.d.ts.map