generated from NYCPlanning/ae-remix-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup-test.ts
42 lines (35 loc) · 995 Bytes
/
setup-test.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
39
40
41
42
import "@testing-library/jest-dom";
/**
* Handlers are automatically generated with Kubb from Open API documentation
*/
import { handlers } from "./app/gen";
import { setupServer } from "msw/node";
window.URL.createObjectURL = vi.fn();
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(),
})),
});
Object.defineProperty(window, "scrollTo", {
writable: true,
value: vi.fn(),
});
Object.defineProperty(window, "_paq", {
writable: true,
value: [],
});
/**
* Mock Service Worker can be configured once the Handlers are generated
*/
const server = setupServer(...handlers);
beforeAll(() => server.listen({ onUnhandledRequest: "error" }));
afterAll(() => server.close());
afterEach(() => server.resetHandlers());