File tree 1 file changed +33
-0
lines changed
packages/react-query/src/__tests__
1 file changed +33
-0
lines changed Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ import { ErrorBoundary } from 'react-error-boundary'
5
5
import {
6
6
QueryCache ,
7
7
QueryErrorResetBoundary ,
8
+ skipToken ,
8
9
useQueryErrorResetBoundary ,
9
10
useSuspenseInfiniteQuery ,
10
11
useSuspenseQuery ,
@@ -870,4 +871,36 @@ describe('useSuspenseQuery', () => {
870
871
await waitFor ( ( ) => rendered . getByText ( 'loading' ) )
871
872
await waitFor ( ( ) => rendered . getByText ( 'data: 2' ) )
872
873
} )
874
+
875
+ it ( 'should log an error when skipToken is passed as queryFn' , ( ) => {
876
+ const consoleErrorSpy = vi
877
+ . spyOn ( console , 'error' )
878
+ . mockImplementation ( ( ) => { } )
879
+ const key = queryKey ( )
880
+
881
+ function Page ( ) {
882
+ useSuspenseQuery ( {
883
+ queryKey : key ,
884
+ // @ts -expect-error
885
+ queryFn : Math . random ( ) >= 0 ? skipToken : ( ) => Promise . resolve ( 5 ) ,
886
+ } )
887
+
888
+ return null
889
+ }
890
+
891
+ function App ( ) {
892
+ return (
893
+ < React . Suspense fallback = "Loading..." >
894
+ < Page />
895
+ </ React . Suspense >
896
+ )
897
+ }
898
+
899
+ renderWithClient ( queryClient , < App /> )
900
+
901
+ expect ( consoleErrorSpy ) . toHaveBeenCalledWith (
902
+ 'skipToken is not allowed for useSuspenseQuery' ,
903
+ )
904
+ consoleErrorSpy . mockRestore ( )
905
+ } )
873
906
} )
You can’t perform that action at this time.
0 commit comments