@somnia-chain/markets-sdk


@somnia-chain/markets-sdk / index / debugCollector

Function: debugCollector()

debugCollector(): DebugCollector

Defined in: packages/sdk/src/debug.ts:396

Build a fresh event collector — the test-side counterpart of consoleDebugSink, for asserting that an operation produced the spans/logs you expect (or for ad-hoc capture in a REPL).

Returns

DebugCollector

An independent DebugCollector; nothing is shared between calls, so parallel tests can each have their own.

Example

Assert a trader write went through the execute pipeline exactly once:

ts
const collector = debugCollector();
const exchange = new SomniaMarkets({ ...config, debug: collector.sink });
await exchange.trader.placeOrder(params);
expect(collector.starts("trade.execute")).toHaveLength(1);
expect(collector.ends("trade.execute")[0].error).toBeUndefined();