Allow node to report load time errors

[Fixes #153466462]
This commit is contained in:
Steve Gravrock
2018-02-17 15:45:42 -08:00
parent 785f62c7a0
commit 1ac2a6f608
6 changed files with 75 additions and 44 deletions

View File

@@ -38,17 +38,29 @@ getJasmineRequireObj().Env = function(j$) {
return currentSpec || currentSuite();
};
var globalErrors = new j$.GlobalErrors();
globalErrors.install();
globalErrors.pushListener(function(message, filename, lineno) {
topSuite.result.failedExpectations.push({
passed: false,
globalErrorType: 'load',
message: message,
filename: filename,
lineno: lineno
var globalErrors = null;
var installGlobalErrors = function() {
if (globalErrors) {
return;
}
globalErrors = new j$.GlobalErrors();
globalErrors.install();
};
if (!options.suppressLoadErrors) {
installGlobalErrors();
globalErrors.pushListener(function(message, filename, lineno) {
topSuite.result.failedExpectations.push({
passed: false,
globalErrorType: 'load',
message: message,
filename: filename,
lineno: lineno
});
});
});
}
this.specFilter = function() {
return true;
@@ -193,13 +205,6 @@ getJasmineRequireObj().Env = function(j$) {
return seed;
};
this.suppressLoadErrors = function() {
if (handlingLoadErrors) {
globalErrors.popListener();
}
handlingLoadErrors = false;
};
this.deprecated = function(deprecation) {
var runnable = currentRunnable() || topSuite;
runnable.addDeprecationWarning(deprecation);
@@ -309,7 +314,7 @@ getJasmineRequireObj().Env = function(j$) {
this.execute = function(runnablesToRun) {
var self = this;
this.suppressLoadErrors();
installGlobalErrors();
if(!runnablesToRun) {
if (focusedRunnables.length) {