Skip to content

Commit

Permalink
test: Fix uncaught errors while testing on Cast (#7345)
Browse files Browse the repository at this point in the history
We get strange uncaught errors sometimes on Cast devices. These are
unreadable "script error" events that have nothing to do with our tests
(see https://sentry.io/answers/script-error/), and we intend to ignore
them.

However, our existing logic to ignore those is not sufficient, because
in addition to our own error handler (via
window.addEventListener("error")), Jasmine has its own unconditional
error handler (via window.onerror).

To take complete control over how these are handled, we need to remove
Jasmine's handler.

Jasmine's handler is installed at the top of its execute() function, so
our top-level beforeAll() is the best place to remove it.
  • Loading branch information
joeyparrish committed Sep 20, 2024
1 parent e297339 commit cc3dc1d
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion test/test/boot.js
Original file line number Diff line number Diff line change
Expand Up @@ -347,9 +347,13 @@ function configureJasmineEnvironment() {
shaka.log.setLevel(shaka.log.Level.INFO);
}

// Ensure node modules are loaded before any tests execute.
beforeAll(async () => {
// Ensure node modules are loaded before any tests execute.
await loadNodeModules();

// Replace jasmine's global error handler, since we have our own more
// nuanced version.
window.onerror = null;
});

const originalSetTimeout = window.setTimeout;
Expand Down

0 comments on commit cc3dc1d

Please sign in to comment.