Skip to content

Commit 8ab0ee5

Browse files
committed
test(query-devtools/Devtools): use 'vi.useFakeTimers' and 'vi.advanceTimersByTimeAsync' for microtask flush
1 parent 58f3a1f commit 8ab0ee5

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

packages/query-devtools/src/__tests__/Devtools.test.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ describe('Devtools', () => {
3232
let previousRootFontSize = ''
3333

3434
beforeEach(() => {
35+
vi.useFakeTimers()
3536
previousRootFontSize = document.documentElement.style.fontSize
3637
// jsdom doesn't implement `PointerEvent`; the DropdownMenu trigger checks
3738
// `e.pointerType !== 'touch'` on pointerdown to decide whether to open,
@@ -101,6 +102,7 @@ describe('Devtools', () => {
101102
})
102103

103104
afterEach(() => {
105+
vi.useRealTimers()
104106
vi.unstubAllGlobals()
105107
Object.keys(storage).forEach((key) => delete storage[key])
106108
queryClient.clear()
@@ -344,7 +346,7 @@ describe('Devtools', () => {
344346
mutationFn: () => Promise.resolve('ok'),
345347
})
346348
mutation.execute({})
347-
await Promise.resolve()
349+
await vi.advanceTimersByTimeAsync(0)
348350

349351
expect(
350352
rendered.getByLabelText(/Mutation submitted at/),

0 commit comments

Comments
 (0)