@@ -72,7 +72,9 @@ describe('useIsMutating', () => {
72
72
< Page />
73
73
</ QueryClientProvider >
74
74
) )
75
- await vi . waitFor ( ( ) => expect ( isMutatingArray ) . toEqual ( [ 0 , 1 , 2 , 1 , 0 ] ) )
75
+
76
+ await vi . advanceTimersByTimeAsync ( 150 )
77
+ expect ( isMutatingArray ) . toEqual ( [ 0 , 1 , 2 , 1 , 0 ] )
76
78
} )
77
79
78
80
it ( 'should filter correctly by mutationKey' , async ( ) => {
@@ -116,8 +118,10 @@ describe('useIsMutating', () => {
116
118
< Page />
117
119
</ QueryClientProvider >
118
120
) )
121
+
119
122
// Unlike React, IsMutating Wont re-render twice with mutation2
120
- await vi . waitFor ( ( ) => expect ( isMutatingArray ) . toEqual ( [ 0 , 1 , 0 ] ) )
123
+ await vi . advanceTimersByTimeAsync ( 100 )
124
+ expect ( isMutatingArray ) . toEqual ( [ 0 , 1 , 0 ] )
121
125
} )
122
126
123
127
it ( 'should filter correctly by predicate' , async ( ) => {
@@ -166,7 +170,8 @@ describe('useIsMutating', () => {
166
170
) )
167
171
168
172
// Again, No unnecessary re-renders like React
169
- await vi . waitFor ( ( ) => expect ( isMutatingArray ) . toEqual ( [ 0 , 1 , 0 ] ) )
173
+ await vi . advanceTimersByTimeAsync ( 100 )
174
+ expect ( isMutatingArray ) . toEqual ( [ 0 , 1 , 0 ] )
170
175
} )
171
176
172
177
it ( 'should use provided custom queryClient' , async ( ) => {
@@ -196,9 +201,8 @@ describe('useIsMutating', () => {
196
201
197
202
const rendered = render ( ( ) => < Page > </ Page > )
198
203
199
- await vi . waitFor ( ( ) =>
200
- expect ( rendered . getByText ( 'mutating: 1' ) ) . toBeInTheDocument ( ) ,
201
- )
204
+ await vi . advanceTimersByTimeAsync ( 0 )
205
+ expect ( rendered . getByText ( 'mutating: 1' ) ) . toBeInTheDocument ( )
202
206
} )
203
207
204
208
// eslint-disable-next-line vitest/expect-expect
0 commit comments