Merge branch 'unhandledrejection' of https://github.com/johnjbarton/jasmine into browser-unhandled-rejections

* Merges #1778 from @johnjbarton
* Fixes #1777
This commit is contained in:
Steve Gravrock
2020-01-15 20:11:05 -08:00
3 changed files with 64 additions and 0 deletions

View File

@@ -3848,8 +3848,25 @@ getJasmineRequireObj().GlobalErrors = function(j$) {
var originalHandler = global.onerror;
global.onerror = onerror;
var browserRejectionHandler = function browserRejectionHandler(event) {
onerror('Unhandled Rejection: ' + event.reason);
};
if (global.addEventListener) {
global.addEventListener(
'unhandledrejection',
browserRejectionHandler
);
}
this.uninstall = function uninstall() {
global.onerror = originalHandler;
if (global.removeEventListener) {
global.removeEventListener(
'unhandledrejection',
browserRejectionHandler
);
}
};
}
};