Add a unit test for the global error handling including stacktrace

This commit is contained in:
Ferdinand Prantl
2019-07-16 12:00:09 +02:00
parent df4b6e58e2
commit 4858a62fdc

View File

@@ -12,6 +12,20 @@ describe('GlobalErrors', function() {
expect(handler).toHaveBeenCalledWith('foo');
});
it('prefers passing the error including stack to the handler', function() {
var fakeGlobal = { onerror: null },
handler = jasmine.createSpy('errorHandler'),
errors = new jasmineUnderTest.GlobalErrors(fakeGlobal),
fooError = new Error('foo');
errors.install();
errors.pushListener(handler);
fakeGlobal.onerror(fooError.message, 'foo.js', 1, 1, fooError);
expect(handler).toHaveBeenCalledWith(fooError);
});
it('only calls the most recent handler', function() {
var fakeGlobal = { onerror: null },
handler1 = jasmine.createSpy('errorHandler1'),