Skip to content

Commit 6751b6d

Browse files
committed
test: check for AbortController existence
Running tests comparitively on older versions of Node.js that do not have AbortController can be a pain. Only add the AbortController to knownGlobals if it actually exists. Signed-off-by: James M Snell <jasnell@gmail.com> PR-URL: #35616 Reviewed-By: Denys Otrishko <shishugi@gmail.com> Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Richard Lau <rlau@redhat.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
1 parent f59d4e0 commit 6751b6d

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

test/common/index.js

+9-1
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,6 @@ function platformTimeout(ms) {
253253
}
254254

255255
let knownGlobals = [
256-
AbortController,
257256
clearImmediate,
258257
clearInterval,
259258
clearTimeout,
@@ -264,6 +263,15 @@ let knownGlobals = [
264263
queueMicrotask,
265264
];
266265

266+
// TODO(@jasnell): This check can be temporary. AbortController is
267+
// not currently supported in either Node.js 12 or 10, making it
268+
// difficult to run tests comparitively on those versions. Once
269+
// all supported versions have AbortController as a global, this
270+
// check can be removed and AbortController can be added to the
271+
// knownGlobals list above.
272+
if (global.AbortController)
273+
knownGlobals.push(global.AbortController);
274+
267275
if (global.gc) {
268276
knownGlobals.push(global.gc);
269277
}

0 commit comments

Comments
 (0)