Skip to content
Source
Sign inSign up
TanStack/query
Open History to see the last commit

test-setup.ts

17 lines543 Bytes

1import { notifyManager } from '@tanstack/query-core'
2import '@testing-library/jest-dom/vitest'
3import { act, cleanup as cleanupRTL } from '@testing-library/preact'
4import { afterEach } from 'vitest'
5​
6// https://testing-library.com/docs/preact-testing-library/api#cleanup
7// Wrap in act so effect cleanups Preact defers on unmount run synchronously
8afterEach(() => {
9 act(() => {
10 cleanupRTL()
11 })
12})
13​
14// Wrap notifications with act to make sure React knows about React Query updates
15notifyManager.setNotifyFunction((fn) => {
16 act(fn)
17})