Skip to content

Commit da589fb

Browse files
committed
.
1 parent 071cd8b commit da589fb

File tree

1 file changed

+20
-13
lines changed

1 file changed

+20
-13
lines changed

vitest.setup.ts

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,27 @@ vi.mock("next/navigation", () => ({
1616
redirect: vi.fn(),
1717
}));
1818

19-
vi.mock("@/lib/auth/auth", () => ({
20-
auth: {
21-
api: {
22-
getSession: vi.fn(() =>
23-
Promise.resolve({
24-
user: {
25-
26-
name: "Test User",
27-
},
28-
}),
29-
),
19+
// Partially mock auth only for getSession; keep other exports (encrypt, decrypt, etc.) intact
20+
vi.mock("@/lib/auth/auth", async (importOriginal) => {
21+
const actual = (await importOriginal()) as unknown as {
22+
auth: { api: { getSession: (...args: unknown[]) => unknown } };
23+
[k: string]: unknown;
24+
};
25+
return {
26+
...actual,
27+
auth: {
28+
...actual.auth,
29+
api: {
30+
...actual.auth.api,
31+
getSession: vi.fn(() =>
32+
Promise.resolve({
33+
user: { email: "[email protected]", name: "Test User" },
34+
}),
35+
),
36+
},
3037
},
31-
},
32-
}));
38+
};
39+
});
3340

3441
// Common UI/runtime mocks
3542
vi.mock("next/image", () => ({

0 commit comments

Comments
 (0)