forked from TanStack/query
-
Notifications
You must be signed in to change notification settings - Fork 0
/
jest.setup.js
38 lines (30 loc) · 885 Bytes
/
jest.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
import { act } from '@testing-library/react'
import { notifyManager } from '@tanstack/query-core'
// Wrap notifications with act to make sure React knows about React Query updates
notifyManager.setNotifyFunction((fn) => {
act(fn)
})
jest.mock('react', () => {
const packages = {
18: 'react',
17: 'react-17',
}
const version = process.env.REACTJS_VERSION || '18'
return jest.requireActual(packages[version])
})
jest.mock('react-dom', () => {
const packages = {
18: 'react-dom',
17: 'react-dom-17',
}
const version = process.env.REACTJS_VERSION || '18'
return jest.requireActual(packages[version])
})
jest.mock('@testing-library/react', () => {
const packages = {
18: '@testing-library/react',
17: '@testing-library/react-17',
}
const version = process.env.REACTJS_VERSION || '18'
return jest.requireActual(packages[version])
})