diff --git a/packages/preact-query/src/__tests__/useMutation.test.tsx b/packages/preact-query/src/__tests__/useMutation.test.tsx index 71d9f58c849..4254394933a 100644 --- a/packages/preact-query/src/__tests__/useMutation.test.tsx +++ b/packages/preact-query/src/__tests__/useMutation.test.tsx @@ -1798,7 +1798,7 @@ describe('useMutation', () => { onTestFinished, }) => { const unhandledRejectionFn = vi.fn() - process.on('unhandledRejection', (error) => unhandledRejectionFn(error)) + process.on('unhandledRejection', unhandledRejectionFn) onTestFinished(() => { process.off('unhandledRejection', unhandledRejectionFn) }) @@ -1843,7 +1843,7 @@ describe('useMutation', () => { onTestFinished, }) => { const unhandledRejectionFn = vi.fn() - process.on('unhandledRejection', (error) => unhandledRejectionFn(error)) + process.on('unhandledRejection', unhandledRejectionFn) onTestFinished(() => { process.off('unhandledRejection', unhandledRejectionFn) }) diff --git a/packages/query-core/src/__tests__/mutation.test.tsx b/packages/query-core/src/__tests__/mutation.test.tsx index 6fdd1d5ebd0..e2dfe583dd7 100644 --- a/packages/query-core/src/__tests__/mutation.test.tsx +++ b/packages/query-core/src/__tests__/mutation.test.tsx @@ -963,7 +963,7 @@ describe('mutation', () => { queryClient.mount() const unhandledRejectionFn = vi.fn() - process.on('unhandledRejection', (error) => unhandledRejectionFn(error)) + process.on('unhandledRejection', unhandledRejectionFn) onTestFinished(() => { process.off('unhandledRejection', unhandledRejectionFn) }) @@ -1015,7 +1015,11 @@ describe('mutation', () => { ]) expect(unhandledRejectionFn).toHaveBeenCalledTimes(1) - expect(unhandledRejectionFn).toHaveBeenNthCalledWith(1, newMutationError) + expect(unhandledRejectionFn).toHaveBeenNthCalledWith( + 1, + newMutationError, + expect.any(Promise), + ) expect(mutationError).toEqual(newMutationError) }) @@ -1024,7 +1028,7 @@ describe('mutation', () => { onTestFinished, }) => { const unhandledRejectionFn = vi.fn() - process.on('unhandledRejection', (error) => unhandledRejectionFn(error)) + process.on('unhandledRejection', unhandledRejectionFn) onTestFinished(() => { process.off('unhandledRejection', unhandledRejectionFn) }) @@ -1079,7 +1083,11 @@ describe('mutation', () => { ]) expect(unhandledRejectionFn).toHaveBeenCalledTimes(1) - expect(unhandledRejectionFn).toHaveBeenNthCalledWith(1, newMutationError) + expect(unhandledRejectionFn).toHaveBeenNthCalledWith( + 1, + newMutationError, + expect.any(Promise), + ) expect(mutationError).toEqual(newMutationError) }) @@ -1088,7 +1096,7 @@ describe('mutation', () => { onTestFinished, }) => { const unhandledRejectionFn = vi.fn() - process.on('unhandledRejection', (error) => unhandledRejectionFn(error)) + process.on('unhandledRejection', unhandledRejectionFn) onTestFinished(() => { process.off('unhandledRejection', unhandledRejectionFn) }) @@ -1156,13 +1164,26 @@ describe('mutation', () => { expect(mutationError).toEqual(newMutationError) expect(unhandledRejectionFn).toHaveBeenCalledTimes(4) - expect(unhandledRejectionFn).toHaveBeenNthCalledWith(1, globalErrorError) - expect(unhandledRejectionFn).toHaveBeenNthCalledWith(2, newErrorError) + expect(unhandledRejectionFn).toHaveBeenNthCalledWith( + 1, + globalErrorError, + expect.any(Promise), + ) + expect(unhandledRejectionFn).toHaveBeenNthCalledWith( + 2, + newErrorError, + expect.any(Promise), + ) expect(unhandledRejectionFn).toHaveBeenNthCalledWith( 3, globalSettledError, + expect.any(Promise), + ) + expect(unhandledRejectionFn).toHaveBeenNthCalledWith( + 4, + newSettledError, + expect.any(Promise), ) - expect(unhandledRejectionFn).toHaveBeenNthCalledWith(4, newSettledError) }) }) diff --git a/packages/query-core/src/__tests__/mutationObserver.test.tsx b/packages/query-core/src/__tests__/mutationObserver.test.tsx index 759734a0a6c..f44343dca6e 100644 --- a/packages/query-core/src/__tests__/mutationObserver.test.tsx +++ b/packages/query-core/src/__tests__/mutationObserver.test.tsx @@ -431,7 +431,7 @@ describe('mutationObserver', () => { onTestFinished, }) => { const unhandledRejectionFn = vi.fn() - process.on('unhandledRejection', (error) => unhandledRejectionFn(error)) + process.on('unhandledRejection', unhandledRejectionFn) onTestFinished(() => { process.off('unhandledRejection', unhandledRejectionFn) }) @@ -463,8 +463,16 @@ describe('mutationObserver', () => { expect(onSettled).toHaveBeenCalledTimes(1) expect(unhandledRejectionFn).toHaveBeenCalledTimes(2) - expect(unhandledRejectionFn).toHaveBeenNthCalledWith(1, onSuccessError) - expect(unhandledRejectionFn).toHaveBeenNthCalledWith(2, onSettledError) + expect(unhandledRejectionFn).toHaveBeenNthCalledWith( + 1, + onSuccessError, + expect.any(Promise), + ) + expect(unhandledRejectionFn).toHaveBeenNthCalledWith( + 2, + onSettledError, + expect.any(Promise), + ) expect(subscriptionHandler).toHaveBeenCalledTimes(2) @@ -475,7 +483,7 @@ describe('mutationObserver', () => { onTestFinished, }) => { const unhandledRejectionFn = vi.fn() - process.on('unhandledRejection', (error) => unhandledRejectionFn(error)) + process.on('unhandledRejection', unhandledRejectionFn) onTestFinished(() => { process.off('unhandledRejection', unhandledRejectionFn) }) @@ -510,8 +518,16 @@ describe('mutationObserver', () => { expect(onSettled).toHaveBeenCalledTimes(1) expect(unhandledRejectionFn).toHaveBeenCalledTimes(2) - expect(unhandledRejectionFn).toHaveBeenNthCalledWith(1, onErrorError) - expect(unhandledRejectionFn).toHaveBeenNthCalledWith(2, onSettledError) + expect(unhandledRejectionFn).toHaveBeenNthCalledWith( + 1, + onErrorError, + expect.any(Promise), + ) + expect(unhandledRejectionFn).toHaveBeenNthCalledWith( + 2, + onSettledError, + expect.any(Promise), + ) expect(subscriptionHandler).toHaveBeenCalledTimes(2) diff --git a/packages/react-query/src/__tests__/useMutation.test.tsx b/packages/react-query/src/__tests__/useMutation.test.tsx index e885b8e244c..f78f1ab1e54 100644 --- a/packages/react-query/src/__tests__/useMutation.test.tsx +++ b/packages/react-query/src/__tests__/useMutation.test.tsx @@ -1797,7 +1797,7 @@ describe('useMutation', () => { onTestFinished, }) => { const unhandledRejectionFn = vi.fn() - process.on('unhandledRejection', (error) => unhandledRejectionFn(error)) + process.on('unhandledRejection', unhandledRejectionFn) onTestFinished(() => { process.off('unhandledRejection', unhandledRejectionFn) }) @@ -1842,7 +1842,7 @@ describe('useMutation', () => { onTestFinished, }) => { const unhandledRejectionFn = vi.fn() - process.on('unhandledRejection', (error) => unhandledRejectionFn(error)) + process.on('unhandledRejection', unhandledRejectionFn) onTestFinished(() => { process.off('unhandledRejection', unhandledRejectionFn) }) diff --git a/packages/solid-query/src/__tests__/useMutation.test.tsx b/packages/solid-query/src/__tests__/useMutation.test.tsx index 495dc1290c2..caccf75f078 100644 --- a/packages/solid-query/src/__tests__/useMutation.test.tsx +++ b/packages/solid-query/src/__tests__/useMutation.test.tsx @@ -1403,7 +1403,7 @@ describe('useMutation', () => { onTestFinished, }) => { const unhandledRejectionFn = vi.fn() - process.on('unhandledRejection', (error) => unhandledRejectionFn(error)) + process.on('unhandledRejection', unhandledRejectionFn) onTestFinished(() => { process.off('unhandledRejection', unhandledRejectionFn) }) @@ -1448,7 +1448,7 @@ describe('useMutation', () => { onTestFinished, }) => { const unhandledRejectionFn = vi.fn() - process.on('unhandledRejection', (error) => unhandledRejectionFn(error)) + process.on('unhandledRejection', unhandledRejectionFn) onTestFinished(() => { process.off('unhandledRejection', unhandledRejectionFn) })