@@ -74,6 +74,9 @@ test('ensures the given callback is a function', () => {
74
74
)
75
75
} )
76
76
77
+ const testAbortController =
78
+ typeof AbortController === 'undefined' ? test . skip : test
79
+
77
80
describe ( 'using fake modern timers' , ( ) => {
78
81
beforeEach ( ( ) => {
79
82
jest . useFakeTimers ( 'modern' )
@@ -220,7 +223,7 @@ describe('using fake modern timers', () => {
220
223
` )
221
224
} )
222
225
223
- test ( 'can be aborted with an AbortSignal' , async ( ) => {
226
+ testAbortController ( 'can be aborted with an AbortSignal' , async ( ) => {
224
227
const callback = jest . fn ( ( ) => {
225
228
throw new Error ( 'not done' )
226
229
} )
@@ -238,21 +241,24 @@ describe('using fake modern timers', () => {
238
241
expect ( callback ) . toHaveBeenCalledTimes ( 2 )
239
242
} )
240
243
241
- test ( 'does not even ping if the signal is already aborted' , async ( ) => {
242
- const callback = jest . fn ( ( ) => {
243
- throw new Error ( 'not done' )
244
- } )
245
- const controller = new AbortController ( )
246
- controller . abort ( 'Bailing out' )
244
+ testAbortController (
245
+ 'does not even ping if the signal is already aborted' ,
246
+ async ( ) => {
247
+ const callback = jest . fn ( ( ) => {
248
+ throw new Error ( 'not done' )
249
+ } )
250
+ const controller = new AbortController ( )
251
+ controller . abort ( 'Bailing out' )
247
252
248
- const waitForError = waitFor ( callback , {
249
- signal : controller . signal ,
250
- } )
253
+ const waitForError = waitFor ( callback , {
254
+ signal : controller . signal ,
255
+ } )
251
256
252
- await expect ( waitForError ) . rejects . toThrowErrorMatchingInlineSnapshot (
253
- `Aborted: Bailing out` ,
254
- )
255
- // Just the initial check
256
- expect ( callback ) . toHaveBeenCalledTimes ( 1 )
257
- } )
257
+ await expect ( waitForError ) . rejects . toThrowErrorMatchingInlineSnapshot (
258
+ `Aborted: Bailing out` ,
259
+ )
260
+ // Just the initial check
261
+ expect ( callback ) . toHaveBeenCalledTimes ( 1 )
262
+ } ,
263
+ )
258
264
} )
0 commit comments