@@ -713,4 +713,76 @@ describe('useSuspenseQueries 2', () => {
713
713
)
714
714
consoleErrorSpy . mockRestore ( )
715
715
} )
716
+
717
+ it ( 'should log an error when skipToken is used in development environment' , ( ) => {
718
+ const envCopy = process . env . NODE_ENV
719
+ process . env . NODE_ENV = 'development'
720
+
721
+ const consoleErrorSpy = vi
722
+ . spyOn ( console , 'error' )
723
+ . mockImplementation ( ( ) => undefined )
724
+ const key = queryKey ( )
725
+
726
+ function Page ( ) {
727
+ useSuspenseQueries ( {
728
+ queries : [
729
+ {
730
+ queryKey : key ,
731
+ queryFn : skipToken as any ,
732
+ } ,
733
+ ] ,
734
+ } )
735
+
736
+ return null
737
+ }
738
+
739
+ renderWithClient (
740
+ queryClient ,
741
+ < React . Suspense fallback = "Loading..." >
742
+ < Page />
743
+ </ React . Suspense > ,
744
+ )
745
+
746
+ expect ( consoleErrorSpy ) . toHaveBeenCalledWith (
747
+ 'skipToken is not allowed for useSuspenseQueries' ,
748
+ )
749
+
750
+ consoleErrorSpy . mockRestore ( )
751
+ process . env . NODE_ENV = envCopy
752
+ } )
753
+
754
+ it ( 'should not log an error when skipToken is used in production environment' , ( ) => {
755
+ const envCopy = process . env . NODE_ENV
756
+ process . env . NODE_ENV = 'production'
757
+
758
+ const consoleErrorSpy = vi
759
+ . spyOn ( console , 'error' )
760
+ . mockImplementation ( ( ) => undefined )
761
+ const key = queryKey ( )
762
+
763
+ function Page ( ) {
764
+ useSuspenseQueries ( {
765
+ queries : [
766
+ {
767
+ queryKey : key ,
768
+ queryFn : skipToken as any ,
769
+ } ,
770
+ ] ,
771
+ } )
772
+
773
+ return null
774
+ }
775
+
776
+ renderWithClient (
777
+ queryClient ,
778
+ < React . Suspense fallback = "Loading..." >
779
+ < Page />
780
+ </ React . Suspense > ,
781
+ )
782
+
783
+ expect ( consoleErrorSpy ) . not . toHaveBeenCalled ( )
784
+
785
+ consoleErrorSpy . mockRestore ( )
786
+ process . env . NODE_ENV = envCopy
787
+ } )
716
788
} )
0 commit comments