import { n as CommandSpan, r as ErrorSink, t as AnalyticsSink } from "./sinks-CSEolKcN.mjs"; import { i as Logger } from "./logger-CxGXigv1.mjs"; import { r as createLogger } from "./create-CEY3e4NQ.mjs"; import { Mock } from "vitest"; //#region src/testing/fake-analytics-sink.d.ts /** An {@link AnalyticsSink} whose methods are spies. */ interface FakeAnalyticsSink extends AnalyticsSink { identify: Mock; capture: Mock; shutdown: Mock<() => Promise>; } /** * Build a spy {@link AnalyticsSink} for asserting what a unit under test * reported. `shutdown()` resolves immediately. * * ```ts * const analytics = fakeAnalyticsSink(); * await deploy({ analytics, branch: "main" }); * expect(analytics.capture).toHaveBeenCalledWith("abc123", "deploy_triggered", { branch: "main" }); * ``` */ export declare function fakeAnalyticsSink(): FakeAnalyticsSink; //#endregion //#region src/testing/fake-error-sink.d.ts /** A {@link CommandSpan} whose methods are spies. */ interface FakeSpan extends CommandSpan { setStatus: Mock; end: Mock; } /** An {@link ErrorSink} whose methods are spies; `startSpan()` returns a {@link FakeSpan}. */ interface FakeErrorSink extends ErrorSink { init: Mock; startSpan: Mock<(name: string) => FakeSpan>; captureException: Mock; endSession: Mock; flush: Mock<() => Promise>; } /** * Build a spy {@link ErrorSink} for asserting what a unit under test reported. * `flush()` resolves immediately; `startSpan()` always returns the same spy * span (its own `setStatus` / `end` are separately assertable). * * ```ts * const errors = fakeErrorSink(); * await deploy({ errors, branch: "main" }); * expect(errors.captureException).not.toHaveBeenCalled(); * ``` */ export declare function fakeErrorSink(): FakeErrorSink; //#endregion //#region src/testing/fake-logger.d.ts /** A {@link Logger} whose level methods are spies; `child()` returns itself. */ interface FakeLogger extends Logger { debug: Mock; info: Mock; warn: Mock; error: Mock; child: Mock; flush: Mock; } /** * Build a spy {@link Logger} for asserting what a unit under test logged. * Pass it wherever a real `Logger` is expected. * * ```ts * const log = fakeLogger(); * await deploy({ logger: log, target: "production" }); * expect(log.info).toHaveBeenCalledWith(expect.objectContaining({ target: "production" }), "deploying"); * ``` */ export declare function fakeLogger(): FakeLogger; //#endregion //#region src/testing/silence-logger.d.ts /** * Replace `createLogger` in the `/logger` module with one that returns a * {@link NoopLogger}, so code under test that builds a real Pino logger stops * writing NDJSON to stdout. Everything else the module exports passes through. * * The replacement is a plain function, not a `vi.fn`, so a consumer's * `resetMocks` / `restoreMocks` setting cannot wipe its implementation. * * `vi.mock` only takes effect in the consumer's own file, so call this from a * vitest setup file: * * ```ts * import { vi } from "vitest"; * * vi.mock("@theholocron/observability/logger", async (importOriginal) => { * const { silenceLogger } = await import("@theholocron/observability/testing"); * return silenceLogger(await importOriginal()); * }); * ``` */ export declare function silenceLogger(actual: T): Omit & { createLogger: typeof createLogger; }; //#endregion export type { FakeAnalyticsSink, FakeErrorSink, FakeLogger, FakeSpan };