File tree Expand file tree Collapse file tree 1 file changed +9
-3
lines changed
packages/query-core/src/__tests__ Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ import { waitFor } from '@testing-library/dom'
1111import { QueryObserver , focusManager } from '..'
1212import { createQueryClient , queryKey , sleep } from './utils'
1313import type { QueryClient , QueryObserverResult } from '..'
14+ import { pendingThenable } from '../thenable'
1415
1516describe ( 'queryObserver' , ( ) => {
1617 let queryClient : QueryClient
@@ -1243,18 +1244,23 @@ describe('queryObserver', () => {
12431244 queryFn : ( ) => 'data' ,
12441245 } )
12451246 const results : Array < QueryObserverResult > = [ ]
1247+
1248+ const success = pendingThenable < void > ( )
12461249
12471250
12481251 const unsubscribe = observer . subscribe ( ( result ) => {
1252+
12491253 results . push ( result )
1254+
1255+ if ( result . status === 'success' ) {
1256+ success . resolve ( )
1257+ }
12501258 } )
12511259
12521260 observer . setOptions ( { queryKey : key , queryFn : ( ) => 'data' , enabled : true } )
12531261
12541262
1255- await waitFor ( ( ) => {
1256- expect ( results . at ( - 1 ) ?. status ) . toBe ( 'success' )
1257- } )
1263+ await success
12581264
12591265 unsubscribe ( )
12601266
You can’t perform that action at this time.
0 commit comments