Skip to content

Commit

Permalink
test: check for AbortController existence
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
jasnell committed Oct 15, 2020
1 parent f59d4e0 commit 6751b6d
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion test/common/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,6 @@ function platformTimeout(ms) {
}

let knownGlobals = [
AbortController,
clearImmediate,
clearInterval,
clearTimeout,
Expand All @@ -264,6 +263,15 @@ let knownGlobals = [
queueMicrotask,
];

// TODO(@jasnell): This check can be temporary. AbortController is
// not currently supported in either Node.js 12 or 10, making it
// difficult to run tests comparitively on those versions. Once
// all supported versions have AbortController as a global, this
// check can be removed and AbortController can be added to the
// knownGlobals list above.
if (global.AbortController)
knownGlobals.push(global.AbortController);

if (global.gc) {
knownGlobals.push(global.gc);
}
Expand Down

0 comments on commit 6751b6d

Please sign in to comment.