Skip to content

Commit 10594d7

Browse files
authored
Merge pull request #5 from prateek3255/fix/devtools-tests
✅ Fix devtools test
2 parents 73f1389 + 23db87d commit 10594d7

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

src/devtools/tests/devtools.test.tsx

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -305,18 +305,24 @@ describe('ReactQueryDevtools', () => {
305305
return 'query-1-result'
306306
})
307307

308-
const query2Result = useQuery(['query-2'], async () => {
309-
await sleep(90)
310-
return 'query-2-result'
311-
})
312-
313308
const query3Result = useQuery(
314309
['query-3'],
315310
async () => {
316-
await sleep(50)
311+
await sleep(10)
317312
return 'query-3-result'
318313
},
319-
{ staleTime: Infinity }
314+
{ staleTime: Infinity, enabled: typeof query1Result.data === 'string' }
315+
)
316+
317+
const query2Result = useQuery(
318+
['query-2'],
319+
async () => {
320+
await sleep(10)
321+
return 'query-2-result'
322+
},
323+
{
324+
enabled: typeof query3Result.data === 'string',
325+
}
320326
)
321327

322328
return (
@@ -356,9 +362,7 @@ describe('ReactQueryDevtools', () => {
356362
expect(queries[2]?.textContent).toEqual(query3Hash)
357363

358364
// Wait for the queries to be resolved
359-
await waitFor(() => {
360-
expect(queryClient.isFetching()).toBe(0)
361-
})
365+
await screen.findByText(/query-1-result query-2-result query-3-result/i)
362366

363367
// When sorted by the last updated date the queries are sorted by the time
364368
// they were updated and since the query-2 takes longest time to complete

0 commit comments

Comments
 (0)