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

@@ -1,7 +1,7 @@
module.exports = function(jasmineRequire) {
var jasmine = jasmineRequire.core(jasmineRequire);
var env = jasmine.getEnv();
var env = jasmine.getEnv({suppressLoadErrors: true});
var jasmineInterface = jasmineRequire.interface(jasmine, env);

View File

@@ -794,17 +794,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;
@@ -949,13 +961,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);
@@ -1065,7 +1070,7 @@ getJasmineRequireObj().Env = function(j$) {
this.execute = function(runnablesToRun) {
var self = this;
this.suppressLoadErrors();
installGlobalErrors();
if(!runnablesToRun) {
if (focusedRunnables.length) {

View File

@@ -23,7 +23,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
module.exports = function(jasmineRequire) {
var jasmine = jasmineRequire.core(jasmineRequire);
var env = jasmine.getEnv();
var env = jasmine.getEnv({suppressLoadErrors: true});
var jasmineInterface = jasmineRequire.interface(jasmine, env);