diff --git a/packages/preact-query/src/__tests__/useMutation.test.tsx b/packages/preact-query/src/__tests__/useMutation.test.tsx index b9014e6f629..5c9bc4aa914 100644 --- a/packages/preact-query/src/__tests__/useMutation.test.tsx +++ b/packages/preact-query/src/__tests__/useMutation.test.tsx @@ -1273,8 +1273,10 @@ describe('useMutation', () => { }) }) - // oxlint-disable-next-line vitest/expect-expect - it('should not change state if unmounted', () => { + it('should not change state if unmounted', async () => { + const consoleErrorMock = vi + .spyOn(console, 'error') + .mockReturnValue(undefined) function Mutates() { const { mutate } = useMutation({ mutationFn: () => sleep(10) }) return @@ -1292,6 +1294,8 @@ describe('useMutation', () => { const { getByText } = renderWithClient(queryClient, ) fireEvent.click(getByText('mutate')) fireEvent.click(getByText('unmount')) + await vi.advanceTimersByTimeAsync(10) + expect(consoleErrorMock).not.toHaveBeenCalled() }) it('should be able to throw an error when throwOnError is set to true', async () => {