-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsetupTests.ts
27 lines (22 loc) · 911 Bytes
/
setupTests.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
import { afterEach, vi } from 'vitest'
import { cleanup } from '@testing-library/react'
// extends Vitest's expect method with methods from react-testing-library
import '@testing-library/jest-dom/vitest'
// runs a cleanup after each test case (e.g. clearing jsdom)
afterEach(() => {
cleanup()
})
// vi.spyOn(global.console, 'log').mockImplementation(() => vi.fn())
vi.spyOn(global.console, 'error').mockImplementation(() => vi.fn())
vi.spyOn(global.console, 'warn').mockImplementation(() => vi.fn())
global.crypto.randomUUID = () =>
Math.random().toString() as `${string}-${string}-${string}-${string}-${string}`
vi.stubGlobal('scroll', vi.fn())
vi.mock('zustand')
vi.mock('react-i18next')
process.env = {
...process.env,
// This is needed in order to make the tests work.
// The chosen REACT_APP_API_HOST value is random and could be any string.
REACT_APP_API_HOST: 'http://localhost:8080',
}