Skip to content
This repository has been archived by the owner on Oct 7, 2024. It is now read-only.

Commit

Permalink
Update mocha from v7 to v9
Browse files Browse the repository at this point in the history
`mocha` has been updated to v9. The breaking changes made for v8 and
v9 don't affect us [1][2]. Most notably they include dropping support
for Node.js v10.

The "unhandled rejection" handler setup in the test helper was removed,
as this is now default behaviour in `mocha` as of v8.2.0 [3].

[1]: https://github.com/mochajs/mocha/releases/tag/v9.0.0
[2]: https://github.com/mochajs/mocha/releases/tag/v8.0.0
[3]: mochajs/mocha#2640 (comment)
  • Loading branch information
Gudahtt committed Jun 28, 2021
1 parent 445b74e commit c80808b
Show file tree
Hide file tree
Showing 3 changed files with 267 additions and 243 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"ethereumjs-wallet": "^0.6.3",
"jsdom": "^11.12.0",
"jsdom-global": "^3.0.2",
"mocha": "^7.1.2",
"mocha": "^9.0.1",
"polyfill-crypto.getrandomvalues": "^1.0.0",
"sinon": "^7.2.7"
},
Expand Down
33 changes: 0 additions & 33 deletions test/helper.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
// disallow promises from swallowing errors
enableFailureOnUnhandledPromiseRejection()

const getRandomValuesPoly = require('polyfill-crypto.getrandomvalues')

//
Expand All @@ -24,33 +21,3 @@ if (!window.crypto) {
if (!window.crypto.getRandomValues) {
window.crypto.getRandomValues = getRandomValuesPoly
}

function enableFailureOnUnhandledPromiseRejection (...args) {
// modified from https://github.com/mochajs/mocha/issues/1926#issuecomment-180842722

// rethrow unhandledRejections
if (typeof process !== 'undefined') {
process.on('unhandledRejection', function (reason) {
throw reason
})
} else if (typeof window !== 'undefined') {
// 2016-02-01: No browsers support this natively, however bluebird, when.js,
// and probably other libraries do.
if (typeof window.addEventListener === 'function') {
window.addEventListener('unhandledrejection', function (evt) {
throw evt.detail.reason
})
} else {
const oldOHR = window.onunhandledrejection
window.onunhandledrejection = function (evt) {
if (typeof oldOHR === 'function') {
oldOHR.apply(this, args)
}
throw evt.detail.reason
}
}
} else if (typeof console !== 'undefined' &&
typeof (console.error || console.log) === 'function') {
(console.error || console.log)('Unhandled rejections will be ignored!')
}
}
Loading

0 comments on commit c80808b

Please sign in to comment.