mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
tests - helper - add note
This commit is contained in:
parent
e95ae43c8f
commit
8ae37ae80d
@ -26,27 +26,29 @@ function enableFailureOnUnhandledPromiseRejection() {
|
||||
// overwrite node's promise with the stricter Bluebird promise
|
||||
global.Promise = require('bluebird')
|
||||
|
||||
// modified from https://github.com/mochajs/mocha/issues/1926#issuecomment-180842722
|
||||
|
||||
// rethrow unhandledRejections
|
||||
if (typeof process !== 'undefined') {
|
||||
process.on('unhandledRejection', function (reason) {
|
||||
throw 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;
|
||||
});
|
||||
throw evt.detail.reason
|
||||
})
|
||||
} else {
|
||||
var oldOHR = window.onunhandledrejection;
|
||||
var oldOHR = window.onunhandledrejection
|
||||
window.onunhandledrejection = function (evt) {
|
||||
if (typeof oldOHR === 'function') oldOHR.apply(this, arguments);
|
||||
throw evt.detail.reason;
|
||||
};
|
||||
if (typeof oldOHR === 'function') oldOHR.apply(this, arguments)
|
||||
throw evt.detail.reason
|
||||
}
|
||||
}
|
||||
} else if (typeof console !== 'undefined' &&
|
||||
typeof (console.error || console.log) === 'function') {
|
||||
(console.error || console.log)('Unhandled rejections will be ignored!');
|
||||
(console.error || console.log)('Unhandled rejections will be ignored!')
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user