diff --git a/packages/core/test/exceptions/external-exceptions-handler.spec.ts b/packages/core/test/exceptions/external-exceptions-handler.spec.ts index 8f39cd76f47..9643d65ef59 100644 --- a/packages/core/test/exceptions/external-exceptions-handler.spec.ts +++ b/packages/core/test/exceptions/external-exceptions-handler.spec.ts @@ -2,22 +2,23 @@ import { expect } from 'chai'; import { of } from 'rxjs'; import * as sinon from 'sinon'; import { ExternalExceptionsHandler } from '../../exceptions/external-exceptions-handler'; +import { ExternalExceptionFilter } from '../../exceptions/external-exception-filter'; describe('ExternalExceptionsHandler', () => { let handler: ExternalExceptionsHandler; beforeEach(() => { handler = new ExternalExceptionsHandler(); + + // To avoid showing useless logs + // @ts-ignore + ExternalExceptionFilter.logger.error = () => {}; }); describe('next', () => { - it('should method returns expected stream with message when exception is unknown', async () => { + it('should method returns expected stream with message when exception is unknown', () => { const error = new Error(); - try { - await handler.next(error, null); - } catch (err) { - expect(err).to.be.eql(error); - } + expect(() => handler.next(error, null)).to.throw(error); }); describe('when "invokeCustomFilters" returns value', () => { const observable$ = of(true); @@ -49,6 +50,7 @@ describe('ExternalExceptionsHandler', () => { describe('when filters array is not empty', () => { let filters, funcSpy; class TestException {} + class AnotherTestException {} beforeEach(() => { funcSpy = sinon.spy(); @@ -73,6 +75,12 @@ describe('ExternalExceptionsHandler', () => { }); }); describe('when filter does not exists in filters array', () => { + beforeEach(() => { + filters = [ + { exceptionMetatypes: [AnotherTestException], func: funcSpy }, + ]; + (handler as any).filters = filters; + }); it('should not call funcSpy', () => { handler.invokeCustomFilters(new TestException(), null); expect(funcSpy.notCalled).to.be.true;