forked from Lilly-Protocol/lily-frontend
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstrumentation.test.ts
More file actions
33 lines (27 loc) · 980 Bytes
/
Copy pathinstrumentation.test.ts
File metadata and controls
33 lines (27 loc) · 980 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import { describe, expect, it, vi } from "vitest";
import { onRequestError, register } from "./instrumentation";
describe("Server Instrumentation", () => {
it("registers without throwing an error", () => {
expect(() => register()).not.toThrow();
});
it("handles onRequestError hook without unhandled rejections", async () => {
const error = new Error("Simulated layout render error");
const mockRequest = {
path: "/app/activity",
method: "GET",
headers: { "x-request-id": "test-uuid" },
};
const mockContext = {
routerKind: "App Router" as const,
routePath: "/app/activity",
routeType: "render" as const,
renderSource: "react-server-components" as const,
revalidateReason: undefined,
};
const spy = vi.spyOn(console, "error").mockImplementation(() => {});
await expect(
onRequestError(error, mockRequest, mockContext),
).resolves.not.toThrow();
spy.mockRestore();
});
});