Open History to see the last commit
1import { act } from '@testing-library/react'
2import { notifyManager } from '@tanstack/query-core'
3β
4// Wrap notifications with act to make sure React knows about React Query updates
5notifyManager.setNotifyFunction((fn) => {
6 act(fn)
7})
8β
9type ReactVersion = '18' | '17'
10β
11jest.mock('react', () => {
12 const packages = {
13 '18': 'react',
14 '17': 'react-17',
15 }
16 const version = (process.env.REACTJS_VERSION || '18') as ReactVersion
17β
18 return jest.requireActual(packages[version]!)
19})
20β
21jest.mock('react-dom', () => {
22 const packages = {
23 '18': 'react-dom',
24 '17': 'react-dom-17',
25 }
26 const version = (process.env.REACTJS_VERSION || '18') as ReactVersion
27β
28 return jest.requireActual(packages[version])
29})
30β
31jest.mock('@testing-library/react', () => {
32 const packages = {
33 '18': '@testing-library/react',
34 '17': '@testing-library/react-17',
35 }
36 const version = (process.env.REACTJS_VERSION || '18') as ReactVersion
37β
38 return jest.requireActual(packages[version])
39})