feat(core-shared/instrumentation): withCapture returns Captured<F>
This commit is contained in:
@@ -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>>();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user