From 4858a62fdc55516888c906cb91dc3c37925c44c6 Mon Sep 17 00:00:00 2001 From: Ferdinand Prantl Date: Tue, 16 Jul 2019 12:00:09 +0200 Subject: [PATCH] Add a unit test for the global error handling including stacktrace --- spec/core/GlobalErrorsSpec.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/spec/core/GlobalErrorsSpec.js b/spec/core/GlobalErrorsSpec.js index 9ff19891..b4a54282 100644 --- a/spec/core/GlobalErrorsSpec.js +++ b/spec/core/GlobalErrorsSpec.js @@ -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'),