diff --git a/packages/tanstack-react-query/tests/useQuery.test.tsx b/packages/tanstack-react-query/tests/useQuery.test.tsx index 6ce36949..e6aa2fd6 100644 --- a/packages/tanstack-react-query/tests/useQuery.test.tsx +++ b/packages/tanstack-react-query/tests/useQuery.test.tsx @@ -65,6 +65,36 @@ describe('useQuery', () => { }, { timeout: 500 }); }); + it('should set error during query execution', async () => { + const mockPowerSyncError = { + currentStatus: { status: 'initial' }, + registerListener: vi.fn(() => { }), + onChangeWithCallback: vi.fn(), + resolveTables: vi.fn(() => ['table1', 'table2']), + getAll: vi.fn(() => { + throw new Error('some error'); + }) + }; + + const wrapper = ({ children }) => ( + + {children} + + ); + + const { result } = renderHook(() => useQuery({ + queryKey: ['lists'], + query: 'SELECT * from lists' + }), { wrapper }); + + await waitFor( + async () => { + expect(result.current.error).toEqual(Error('some error')); + }, + { timeout: 100 } + ); + }); + it('should execute compatible queries', async () => { const compilableQuery = { execute: () => [{ test: 'custom' }] as any,