-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetupTests.ts
More file actions
54 lines (48 loc) · 1.19 KB
/
setupTests.ts
File metadata and controls
54 lines (48 loc) · 1.19 KB
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import "@testing-library/jest-dom";
import { vi } from "vitest";
// Configure React to run in development mode for tests
// eslint-disable-next-line @typescript-eslint/no-explicit-any
(globalThis as any).IS_REACT_ACT_ENVIRONMENT = true;
// Mock window.matchMedia
Object.defineProperty(window, "matchMedia", {
writable: true,
value: vi.fn().mockImplementation((query) => ({
matches: false,
media: query,
onchange: null,
addListener: vi.fn(),
removeListener: vi.fn(),
addEventListener: vi.fn(),
removeEventListener: vi.fn(),
dispatchEvent: vi.fn(),
})),
});
// Mock localStorage
Object.defineProperty(window, "localStorage", {
value: {
getItem: vi.fn(),
setItem: vi.fn(),
removeItem: vi.fn(),
clear: vi.fn(),
},
writable: true,
});
// Mock scrollIntoView
Element.prototype.scrollIntoView = vi.fn();
// Mock the auth context
vi.mock("react-oidc-context", () => ({
useAuth: () => ({
isLoading: false,
isAuthenticated: true,
user: {
token: "test-token",
},
signoutRedirect: vi.fn(),
}),
}));
// Mock react-query
vi.mock("@tanstack/react-query", () => ({
useQuery: vi.fn(),
useMutation: vi.fn(),
useQueryClient: vi.fn(),
}));