forked from DiamondLightSource/pato-frontend
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vitest.setup.ts
38 lines (32 loc) · 893 Bytes
/
vitest.setup.ts
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
import "@testing-library/jest-dom";
import { server } from "./src/mocks/server";
import { queryClient } from "./src/utils/test-utils";
import { cleanup } from "@testing-library/react";
export const mockToast = vi.fn();
beforeEach(() => server.listen());
afterEach(() => {
server.resetHandlers();
queryClient.clear();
mockToast.mockClear();
cleanup();
});
afterAll(() => {
server.close();
vi.restoreAllMocks();
});
vi.mock("@chakra-ui/react", async (importOriginal) => {
const actual = await importOriginal<any>();
return {
...actual,
createStandaloneToast: () => ({ toast: mockToast }),
useToast: () => mockToast,
};
});
class ResizeObserver {
observe() {}
unobserve() {}
disconnect() {}
}
global.window.scrollTo = () => {}
global.ResizeObserver = ResizeObserver;
global.structuredClone = (val: Record<string, any>) => JSON.parse(JSON.stringify(val));