-
Notifications
You must be signed in to change notification settings - Fork 0
/
vitest.setup.js
38 lines (32 loc) · 973 Bytes
/
vitest.setup.js
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
// Polyfill "window.fetch" used in the React component.
// import "whatwg-fetch"
import { server } from "./src/mocks/server"
import { beforeAll, afterAll, afterEach, vi } from "vitest"
import { cleanup } from "@testing-library/react"
process.env.NEXT_PUBLIC_APP_VERSION = "0.0.42"
process.env.NEXT_PUBLIC_HASURA_URL = "http://localhost:8080/v1/graphql"
process.env.NEXT_PUBLIC_APP_REPOSITORY_URL =
"https://github.com/SocialGouv/secretariat"
Object.defineProperty(window, "matchMedia", {
writable: true,
value: vi.fn().mockImplementation((query) => ({
matches: false,
media: query,
onchange: null,
addListener: vi.fn(), // deprecated
removeListener: vi.fn(), // deprecated
addEventListener: vi.fn(),
removeEventListener: vi.fn(),
dispatchEvent: vi.fn(),
})),
})
beforeAll(() => {
server.listen({ onUnhandledRequest: "error" })
})
afterEach(() => {
server.resetHandlers()
cleanup()
})
afterAll(() => {
server.close()
})