test: polyfill Promise.allSettled for Node.js <12

This commit is contained in:
Lam Wei Li 2022-07-23 16:16:59 +08:00
parent 39218cc8d0
commit bf57536760
No known key found for this signature in database
GPG Key ID: 90F6ABECF080D7BF

View File

@ -13,3 +13,21 @@ sandbox.configure({
},
},
});
// polyfill for Node.js <12
Promise.allSettled =
Promise.allSettled ||
((promises) =>
Promise.all(
promises.map((p) =>
p
.then((value) => ({
status: 'fulfilled',
value,
}))
.catch((reason) => ({
status: 'rejected',
reason,
}))
)
));