From c9aae2a4b26be48c4c9ea9f9e6e588f818cdecd2 Mon Sep 17 00:00:00 2001 From: eps1lon Date: Thu, 9 Feb 2023 12:20:55 +0100 Subject: [PATCH] Gate AbortController tests We also test Node.js 14 which doesn't support AbortController --- src/__tests__/waitForNode.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/__tests__/waitForNode.js b/src/__tests__/waitForNode.js index f81c050..adcda84 100644 --- a/src/__tests__/waitForNode.js +++ b/src/__tests__/waitForNode.js @@ -74,6 +74,9 @@ test('ensures the given callback is a function', () => { ) }) +const testAbortController = + typeof AbortController === 'undefined' ? test.skip : test + describe('using fake modern timers', () => { beforeEach(() => { jest.useFakeTimers('modern') @@ -220,7 +223,7 @@ describe('using fake modern timers', () => { `) }) - test('can be aborted with an AbortSignal', async () => { + testAbortController('can be aborted with an AbortSignal', async () => { const callback = jest.fn(() => { throw new Error('not done') }) @@ -238,7 +241,7 @@ describe('using fake modern timers', () => { expect(callback).toHaveBeenCalledTimes(2) }) - test('does not even ping if the signal is already aborted', async () => { + testAbortController('does not even ping if the signal is already aborted', async () => { const callback = jest.fn(() => { throw new Error('not done') })