Commit 1bc8749a authored by Robert Knight's avatar Robert Knight

State whether uncaught exception was an exception or a promise

Per PR feedback, be explicit about the kind of exception that occurred.
parent 810bdd5b
...@@ -28,16 +28,20 @@ registerIcons({ ...@@ -28,16 +28,20 @@ registerIcons({
// This works around an issue with mocha / karma-mocha, see // This works around an issue with mocha / karma-mocha, see
// https://github.com/hypothesis/client/issues/2249. // https://github.com/hypothesis/client/issues/2249.
let pendingError = null; let pendingError = null;
let pendingErrorNotice = null;
window.addEventListener('error', event => { window.addEventListener('error', event => {
pendingError = event.error; pendingError = event.error;
pendingErrorNotice = 'An uncaught exception was thrown between tests';
}); });
window.addEventListener('unhandledrejection', event => { window.addEventListener('unhandledrejection', event => {
pendingError = event.reason; pendingError = event.reason;
pendingErrorNotice = 'An uncaught promise rejection occurred between tests';
}); });
afterEach(() => { afterEach(() => {
if (pendingError) { if (pendingError) {
console.error('An uncaught exception was thrown between tests'); console.error(pendingErrorNotice);
throw pendingError; throw pendingError;
} }
}); });
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment