feat(core-shared/instrumentation): withCapture returns Captured<F>

This commit is contained in:
2026-05-12 21:32:42 +02:00
parent 5ac668497f
commit a1fbd16d83
2 changed files with 15 additions and 3 deletions

View File

@@ -1,7 +1,8 @@
import { describe, it, expect, vi } from "vitest";
import { describe, it, expect, expectTypeOf, vi } from "vitest";
import { withCapture } from "@/instrumentation/with-capture";
import type { ILogger } from "@/instrumentation/logger.interface";
import { isReported } from "@/instrumentation/reported-flag";
import type { Captured } from "@/conformance/brands";
function makeLogger(): ILogger & { captureException: ReturnType<typeof vi.fn> } {
return {
@@ -60,3 +61,12 @@ describe("withCapture", () => {
});
});
});
describe("withCapture — brand", () => {
it("returns a Captured<F>", () => {
const logger = makeLogger();
const fn = async (a: number) => a + 1;
const wrapped = withCapture(logger, { layer: "use-case" }, fn);
expectTypeOf(wrapped).toMatchTypeOf<Captured<typeof fn>>();
});
});