Skip to content
Source
Sign inSign up

errorTrace.test.ts

22 lines659 Bytes

1import * as Cause from "effect/Cause";
2import { describe, expect, it } from "vite-plus/test";
3​
4import { findErrorTraceId } from "./errorTrace.ts";
5​
6describe("findErrorTraceId", () => {
7 it("terminates for cyclic causes", () => {
8 const error: { cause?: unknown } = {};
9 error.cause = error;
10​
11 expect(findErrorTraceId(error)).toBeNull();
12 });
13​
14 it("finds trace metadata in Effect cause branches", () => {
15 const cause = Cause.fromReasons<unknown>([
16 Cause.makeFailReason(new Error("first failure")),
17 Cause.makeFailReason({ traceId: "trace-secondary" }),
18 ]);
19​
20 expect(findErrorTraceId(cause)).toBe("trace-secondary");
21 });
22});