Hook the environment to pick up on global errors.
function listenForErrors() {
    window.addEventListener('error', function (event) {
        globalErrors.push(event.error);
    });
    // Also, we treat `console.error` as a test failure. Unless you prefer not.
    var origConsole = console;
    var origError = console.error;
    console.error = function wctShimmedError() {
        origError.apply(origConsole, arguments);
        if (get('trackConsoleError')) {
            throw 'console.error: ' + Array.prototype.join.call(arguments, ' ');
        }
    };
}