@@ -1,7 +1,7 @@
|
|||||||
module.exports = function(jasmineRequire) {
|
module.exports = function(jasmineRequire) {
|
||||||
var jasmine = jasmineRequire.core(jasmineRequire);
|
var jasmine = jasmineRequire.core(jasmineRequire);
|
||||||
|
|
||||||
var env = jasmine.getEnv();
|
var env = jasmine.getEnv({suppressLoadErrors: true});
|
||||||
|
|
||||||
var jasmineInterface = jasmineRequire.interface(jasmine, env);
|
var jasmineInterface = jasmineRequire.interface(jasmine, env);
|
||||||
|
|
||||||
|
|||||||
@@ -794,17 +794,29 @@ getJasmineRequireObj().Env = function(j$) {
|
|||||||
return currentSpec || currentSuite();
|
return currentSpec || currentSuite();
|
||||||
};
|
};
|
||||||
|
|
||||||
var globalErrors = new j$.GlobalErrors();
|
var globalErrors = null;
|
||||||
globalErrors.install();
|
|
||||||
globalErrors.pushListener(function(message, filename, lineno) {
|
var installGlobalErrors = function() {
|
||||||
topSuite.result.failedExpectations.push({
|
if (globalErrors) {
|
||||||
passed: false,
|
return;
|
||||||
globalErrorType: 'load',
|
}
|
||||||
message: message,
|
|
||||||
filename: filename,
|
globalErrors = new j$.GlobalErrors();
|
||||||
lineno: lineno
|
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() {
|
this.specFilter = function() {
|
||||||
return true;
|
return true;
|
||||||
@@ -949,13 +961,6 @@ getJasmineRequireObj().Env = function(j$) {
|
|||||||
return seed;
|
return seed;
|
||||||
};
|
};
|
||||||
|
|
||||||
this.suppressLoadErrors = function() {
|
|
||||||
if (handlingLoadErrors) {
|
|
||||||
globalErrors.popListener();
|
|
||||||
}
|
|
||||||
handlingLoadErrors = false;
|
|
||||||
};
|
|
||||||
|
|
||||||
this.deprecated = function(deprecation) {
|
this.deprecated = function(deprecation) {
|
||||||
var runnable = currentRunnable() || topSuite;
|
var runnable = currentRunnable() || topSuite;
|
||||||
runnable.addDeprecationWarning(deprecation);
|
runnable.addDeprecationWarning(deprecation);
|
||||||
@@ -1065,7 +1070,7 @@ getJasmineRequireObj().Env = function(j$) {
|
|||||||
|
|
||||||
this.execute = function(runnablesToRun) {
|
this.execute = function(runnablesToRun) {
|
||||||
var self = this;
|
var self = this;
|
||||||
this.suppressLoadErrors();
|
installGlobalErrors();
|
||||||
|
|
||||||
if(!runnablesToRun) {
|
if(!runnablesToRun) {
|
||||||
if (focusedRunnables.length) {
|
if (focusedRunnables.length) {
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|||||||
module.exports = function(jasmineRequire) {
|
module.exports = function(jasmineRequire) {
|
||||||
var jasmine = jasmineRequire.core(jasmineRequire);
|
var jasmine = jasmineRequire.core(jasmineRequire);
|
||||||
|
|
||||||
var env = jasmine.getEnv();
|
var env = jasmine.getEnv({suppressLoadErrors: true});
|
||||||
|
|
||||||
var jasmineInterface = jasmineRequire.interface(jasmine, env);
|
var jasmineInterface = jasmineRequire.interface(jasmine, env);
|
||||||
|
|
||||||
|
|||||||
@@ -197,4 +197,24 @@ describe("Env", function() {
|
|||||||
}).not.toThrow();
|
}).not.toThrow();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('when not constructed with suppressLoadErrors: true', function() {
|
||||||
|
it('installs a global error handler on construction', function() {
|
||||||
|
var globalErrors = jasmine.createSpyObj('globalErrors', ['install', 'pushListener', 'popListener']);
|
||||||
|
spyOn(jasmineUnderTest, 'GlobalErrors').and.returnValue(globalErrors);
|
||||||
|
new jasmineUnderTest.Env();
|
||||||
|
expect(globalErrors.install).toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('when constructed with suppressLoadErrors: true', function() {
|
||||||
|
it('does not install a global error handler until execute is called', function() {
|
||||||
|
var globalErrors = jasmine.createSpyObj('globalErrors', ['install', 'pushListener', 'popListener']);
|
||||||
|
spyOn(jasmineUnderTest, 'GlobalErrors').and.returnValue(globalErrors);
|
||||||
|
env = new jasmineUnderTest.Env({suppressLoadErrors: true});
|
||||||
|
expect(globalErrors.install).not.toHaveBeenCalled();
|
||||||
|
env.execute();
|
||||||
|
expect(globalErrors.install).toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -2060,11 +2060,13 @@ describe("Env integration", function() {
|
|||||||
env.execute();
|
env.execute();
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('If suppressLoadErrors was called', function() {
|
describe('If suppressLoadErrors: true was passed', function() {
|
||||||
it('does not report or handle errors that occur during loading', function(done) {
|
it('does not install a global error handler during loading', function(done) {
|
||||||
|
var originalOnerror = jasmine.createSpy('original onerror')
|
||||||
var global = {
|
var global = {
|
||||||
setTimeout: function(fn, delay) { setTimeout(fn, delay) },
|
setTimeout: function(fn, delay) { setTimeout(fn, delay) },
|
||||||
clearTimeout: function(fn, delay) { clearTimeout(fn, delay) }
|
clearTimeout: function(fn, delay) { clearTimeout(fn, delay) },
|
||||||
|
onerror: originalOnerror
|
||||||
};
|
};
|
||||||
spyOn(jasmineUnderTest, 'getGlobal').and.returnValue(global);
|
spyOn(jasmineUnderTest, 'getGlobal').and.returnValue(global);
|
||||||
var globalErrors = new jasmineUnderTest.GlobalErrors(global);
|
var globalErrors = new jasmineUnderTest.GlobalErrors(global);
|
||||||
@@ -2072,17 +2074,16 @@ describe("Env integration", function() {
|
|||||||
globalErrors.pushListener(onerror);
|
globalErrors.pushListener(onerror);
|
||||||
spyOn(jasmineUnderTest, 'GlobalErrors').and.returnValue(globalErrors);
|
spyOn(jasmineUnderTest, 'GlobalErrors').and.returnValue(globalErrors);
|
||||||
|
|
||||||
var env = new jasmineUnderTest.Env(),
|
var env = new jasmineUnderTest.Env({suppressLoadErrors: true});
|
||||||
reporter = jasmine.createSpyObj('reporter', ['jasmineDone', 'suiteDone', 'specDone']);
|
reporter = jasmine.createSpyObj('reporter', ['jasmineDone', 'suiteDone', 'specDone']);
|
||||||
|
|
||||||
reporter.jasmineDone.and.callFake(function(e) {
|
reporter.jasmineDone.and.callFake(function(e) {
|
||||||
expect(e.failedExpectations).toEqual([]);
|
expect(e.failedExpectations).toEqual([]);
|
||||||
expect(onerror).toHaveBeenCalledWith('Uncaught Error: ENOCHEESE');
|
expect(originalOnerror).toHaveBeenCalledWith('Uncaught Error: ENOCHEESE');
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
env.addReporter(reporter);
|
env.addReporter(reporter);
|
||||||
env.suppressLoadErrors(true);
|
|
||||||
global.onerror('Uncaught Error: ENOCHEESE');
|
global.onerror('Uncaught Error: ENOCHEESE');
|
||||||
|
|
||||||
env.execute();
|
env.execute();
|
||||||
|
|||||||
@@ -38,17 +38,29 @@ getJasmineRequireObj().Env = function(j$) {
|
|||||||
return currentSpec || currentSuite();
|
return currentSpec || currentSuite();
|
||||||
};
|
};
|
||||||
|
|
||||||
var globalErrors = new j$.GlobalErrors();
|
var globalErrors = null;
|
||||||
globalErrors.install();
|
|
||||||
globalErrors.pushListener(function(message, filename, lineno) {
|
var installGlobalErrors = function() {
|
||||||
topSuite.result.failedExpectations.push({
|
if (globalErrors) {
|
||||||
passed: false,
|
return;
|
||||||
globalErrorType: 'load',
|
}
|
||||||
message: message,
|
|
||||||
filename: filename,
|
globalErrors = new j$.GlobalErrors();
|
||||||
lineno: lineno
|
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() {
|
this.specFilter = function() {
|
||||||
return true;
|
return true;
|
||||||
@@ -193,13 +205,6 @@ getJasmineRequireObj().Env = function(j$) {
|
|||||||
return seed;
|
return seed;
|
||||||
};
|
};
|
||||||
|
|
||||||
this.suppressLoadErrors = function() {
|
|
||||||
if (handlingLoadErrors) {
|
|
||||||
globalErrors.popListener();
|
|
||||||
}
|
|
||||||
handlingLoadErrors = false;
|
|
||||||
};
|
|
||||||
|
|
||||||
this.deprecated = function(deprecation) {
|
this.deprecated = function(deprecation) {
|
||||||
var runnable = currentRunnable() || topSuite;
|
var runnable = currentRunnable() || topSuite;
|
||||||
runnable.addDeprecationWarning(deprecation);
|
runnable.addDeprecationWarning(deprecation);
|
||||||
@@ -309,7 +314,7 @@ getJasmineRequireObj().Env = function(j$) {
|
|||||||
|
|
||||||
this.execute = function(runnablesToRun) {
|
this.execute = function(runnablesToRun) {
|
||||||
var self = this;
|
var self = this;
|
||||||
this.suppressLoadErrors();
|
installGlobalErrors();
|
||||||
|
|
||||||
if(!runnablesToRun) {
|
if(!runnablesToRun) {
|
||||||
if (focusedRunnables.length) {
|
if (focusedRunnables.length) {
|
||||||
|
|||||||
Reference in New Issue
Block a user