testing/ws_round_trip.ts view source
<TApi extends object>(options: { harness: WsTestHarness; specs: readonly ({ method: string; initiator: "frontend" | "backend" | "both"; side_effects: boolean; input: ZodType<unknown, unknown, $ZodTypeInternals<unknown, unknown>>; ... 7 more ...; rate_limit?: "both" | ... 2 more ... | undefined; } | { ...; } | { ...; })[]; }): TApi Wire a typed broadcast API against the harness's transport, matching
how a consumer's real backend composes the stack. Returns the typed
API so tests can call .tx_run_created(...) / .workspace_changed(...)
etc. directly.
const harness = create_ws_test_harness<BaseHandlerContext>({specs, handlers});
const broadcast = build_broadcast_api<MyBackendActionsApi>({
harness,
specs: my_broadcast_action_specs,
});
const client = await harness.connect(keeper_identity());
await broadcast.tx_run_created({run_id: '...', ...});
await client.wait_for(is_notification('tx_run_created'));options
{ harness: WsTestHarness; specs: readonly ({ method: string; initiator: "frontend" | "backend" | "both"; side_effects: boolean; input: ZodType<unknown, unknown, $ZodTypeInternals<unknown, unknown>>; ... 7 more ...; rate_limit?: "both" | ... 2 more ... | undefined; } | { ...; } | { ...; })[]; }returns
TApi