Skip to content

Commit 293e5e9

Browse files
committed
refactor: do not log undefined query data warning to the console
1 parent 0981378 commit 293e5e9

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/core/tests/query.test.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -805,6 +805,8 @@ describe('query', () => {
805805
})
806806

807807
test('fetch should dispatch an error if the queryFn returns undefined', async () => {
808+
const consoleMock = mockConsoleError()
809+
808810
const key = queryKey()
809811

810812
const observer = new QueryObserver(queryClient, {
@@ -821,12 +823,16 @@ describe('query', () => {
821823

822824
await sleep(10)
823825

826+
const error = new Error('Query data cannot be undefined')
827+
824828
expect(observerResult).toMatchObject({
825829
isError: true,
826-
error: new Error('Query data cannot be undefined'),
830+
error,
827831
})
828832

833+
expect(consoleMock).toHaveBeenCalledWith(error)
829834
unsubscribe()
835+
consoleMock.mockRestore()
830836
})
831837

832838
test('fetch should dispatch fetch if is fetching and current promise is undefined', async () => {

0 commit comments

Comments
 (0)