Load error handling doesn't depend on browser features, so test it everywher

[#24901981]
This commit is contained in:
Steve Gravrock
2017-11-02 18:17:40 -07:00
parent 26a7bc6acf
commit ae9b95269c

View File

@@ -2018,65 +2018,61 @@ describe("Env integration", function() {
env.execute();
});
describe("In a browser", function() {
if (typeof document !== 'undefined') {
it('reports errors that occur during loading', function(done) {
var global = {
setTimeout: function(fn, delay) { setTimeout(fn, delay) },
clearTimeout: function(fn, delay) { clearTimeout(fn, delay) },
};
spyOn(jasmineUnderTest, 'getGlobal').and.returnValue(global);
it('reports errors that occur during loading', function(done) {
var global = {
setTimeout: function(fn, delay) { setTimeout(fn, delay) },
clearTimeout: function(fn, delay) { clearTimeout(fn, delay) },
};
spyOn(jasmineUnderTest, 'getGlobal').and.returnValue(global);
var env = new jasmineUnderTest.Env(),
reporter = jasmine.createSpyObj('reporter', ['jasmineDone', 'suiteDone', 'specDone']);
var env = new jasmineUnderTest.Env(),
reporter = jasmine.createSpyObj('reporter', ['jasmineDone', 'suiteDone', 'specDone']);
reporter.jasmineDone.and.callFake(function(e) {
expect(e.failedExpectations).toEqual([
{
passed: false,
globalErrorType: 'load',
message: 'Uncaught SyntaxError: Unexpected end of input'
},
{
passed: false,
globalErrorType: 'load',
message: 'Uncaught Error: ENOCHEESE'
}
]);
reporter.jasmineDone.and.callFake(function(e) {
expect(e.failedExpectations).toEqual([
{
passed: false,
globalErrorType: 'load',
message: 'Uncaught SyntaxError: Unexpected end of input'
},
{
passed: false,
globalErrorType: 'load',
message: 'Uncaught Error: ENOCHEESE'
}
]);
done();
});
done();
});
env.addReporter(reporter);
global.onerror('Uncaught SyntaxError: Unexpected end of input');
global.onerror('Uncaught Error: ENOCHEESE');
env.addReporter(reporter);
global.onerror('Uncaught SyntaxError: Unexpected end of input');
global.onerror('Uncaught Error: ENOCHEESE');
env.execute();
env.execute();
});
describe('If suppressLoadErrors was called', function() {
it('does not report errors that occur during loading', function(done) {
var global = {
setTimeout: function(fn, delay) { setTimeout(fn, delay) },
clearTimeout: function(fn, delay) { clearTimeout(fn, delay) },
};
spyOn(jasmineUnderTest, 'getGlobal').and.returnValue(global);
var env = new jasmineUnderTest.Env(),
reporter = jasmine.createSpyObj('reporter', ['jasmineDone', 'suiteDone', 'specDone']);
reporter.jasmineDone.and.callFake(function(e) {
expect(e.failedExpectations).toEqual([]);
done();
});
}
describe('If suppressLoadErrors was called', function() {
it('does not report errors that occur during loading', function(done) {
var global = {
setTimeout: function(fn, delay) { setTimeout(fn, delay) },
clearTimeout: function(fn, delay) { clearTimeout(fn, delay) },
};
spyOn(jasmineUnderTest, 'getGlobal').and.returnValue(global);
env.addReporter(reporter);
env.suppressLoadErrors(true);
global.onerror('Uncaught Error: ENOCHEESE');
var env = new jasmineUnderTest.Env(),
reporter = jasmine.createSpyObj('reporter', ['jasmineDone', 'suiteDone', 'specDone']);
reporter.jasmineDone.and.callFake(function(e) {
expect(e.failedExpectations).toEqual([]);
done();
});
env.addReporter(reporter);
env.suppressLoadErrors(true);
global.onerror('Uncaught Error: ENOCHEESE');
env.execute();
});
env.execute();
});
});
});