Skip to content

Commit 7fbb7ac

Browse files
committed
Fixed accidental removal of vitests unhandledRejection handler
1 parent 10e8102 commit 7fbb7ac

1 file changed

Lines changed: 12 additions & 6 deletions

File tree

packages/query-core/src/__tests__/mutationObserver.test.tsx

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -385,13 +385,14 @@ describe('mutationObserver', () => {
385385
})
386386

387387
describe('erroneous mutation callback', () => {
388-
afterEach(() => {
389-
process.removeAllListeners('unhandledRejection')
390-
})
391-
392-
test('onSuccess and onSettled is transferred to different execution context where it is reported', async () => {
388+
test('onSuccess and onSettled is transferred to different execution context where it is reported', async ({
389+
onTestFinished,
390+
}) => {
393391
const unhandledRejectionFn = vi.fn()
394392
process.on('unhandledRejection', (error) => unhandledRejectionFn(error))
393+
onTestFinished(() => {
394+
process.off('unhandledRejection', unhandledRejectionFn)
395+
})
395396

396397
const onSuccessError = new Error('onSuccess-error')
397398
const onSuccess = vi.fn(() => {
@@ -428,9 +429,14 @@ describe('mutationObserver', () => {
428429
unsubscribe()
429430
})
430431

431-
test('onError and onSettled is transferred to different execution context where it is reported', async () => {
432+
test('onError and onSettled is transferred to different execution context where it is reported', async ({
433+
onTestFinished,
434+
}) => {
432435
const unhandledRejectionFn = vi.fn()
433436
process.on('unhandledRejection', (error) => unhandledRejectionFn(error))
437+
onTestFinished(() => {
438+
process.off('unhandledRejection', unhandledRejectionFn)
439+
})
434440

435441
const onErrorError = new Error('onError-error')
436442
const onError = vi.fn(() => {

0 commit comments

Comments
 (0)