File tree Expand file tree Collapse file tree 1 file changed +30
-0
lines changed
packages/tanstack-react-query/tests Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -65,6 +65,36 @@ describe('useQuery', () => {
6565 } , { timeout : 500 } ) ;
6666 } ) ;
6767
68+ it ( 'should set error during query execution' , async ( ) => {
69+ const mockPowerSyncError = {
70+ currentStatus : { status : 'initial' } ,
71+ registerListener : vi . fn ( ( ) => { } ) ,
72+ onChangeWithCallback : vi . fn ( ) ,
73+ resolveTables : vi . fn ( ( ) => [ 'table1' , 'table2' ] ) ,
74+ getAll : vi . fn ( ( ) => {
75+ throw new Error ( 'some error' ) ;
76+ } )
77+ } ;
78+
79+ const wrapper = ( { children } ) => (
80+ < QueryClientProvider client = { queryClient } >
81+ < PowerSyncContext . Provider value = { mockPowerSyncError as any } > { children } </ PowerSyncContext . Provider >
82+ </ QueryClientProvider >
83+ ) ;
84+
85+ const { result } = renderHook ( ( ) => useQuery ( {
86+ queryKey : [ 'lists' ] ,
87+ query : 'SELECT * from lists'
88+ } ) , { wrapper } ) ;
89+
90+ await waitFor (
91+ async ( ) => {
92+ expect ( result . current . error ) . toEqual ( Error ( 'some error' ) ) ;
93+ } ,
94+ { timeout : 100 }
95+ ) ;
96+ } ) ;
97+
6898 it ( 'should execute compatible queries' , async ( ) => {
6999 const compilableQuery = {
70100 execute : ( ) => [ { test : 'custom' } ] as any ,
You can’t perform that action at this time.
0 commit comments