diff --git a/packages/shared-ux/error_boundary/src/services/error_boundary_services.test.tsx b/packages/shared-ux/error_boundary/src/services/error_boundary_services.test.tsx index 8e8838e710e1f..c1842aff3baef 100644 --- a/packages/shared-ux/error_boundary/src/services/error_boundary_services.test.tsx +++ b/packages/shared-ux/error_boundary/src/services/error_boundary_services.test.tsx @@ -17,6 +17,7 @@ import { BadComponent } from '../../mocks'; describe('', () => { let analytics: KibanaErrorBoundaryProviderDeps['analytics']; beforeEach(() => { + jest.spyOn(console, 'error').mockImplementation(() => {}); analytics = analyticsServiceMock.createAnalyticsServiceStart(); }); diff --git a/packages/shared-ux/error_boundary/src/services/error_service.test.ts b/packages/shared-ux/error_boundary/src/services/error_service.test.ts index e89ff74af220f..4f72e997a41e4 100644 --- a/packages/shared-ux/error_boundary/src/services/error_service.test.ts +++ b/packages/shared-ux/error_boundary/src/services/error_service.test.ts @@ -9,6 +9,10 @@ import { KibanaErrorService } from './error_service'; describe('KibanaErrorBoundary Error Service', () => { + beforeEach(() => { + jest.spyOn(console, 'error').mockImplementation(() => {}); + }); + const mockDeps = { analytics: { reportEvent: jest.fn() }, }; diff --git a/packages/shared-ux/error_boundary/src/ui/error_boundary.test.tsx b/packages/shared-ux/error_boundary/src/ui/error_boundary.test.tsx index 472aeba92ad5a..cc95b2978aeca 100644 --- a/packages/shared-ux/error_boundary/src/ui/error_boundary.test.tsx +++ b/packages/shared-ux/error_boundary/src/ui/error_boundary.test.tsx @@ -19,6 +19,7 @@ import { errorMessageStrings as strings } from './message_strings'; describe('', () => { let services: KibanaErrorBoundaryServices; beforeEach(() => { + jest.spyOn(console, 'error').mockImplementation(() => {}); services = getServicesMock(); }); diff --git a/packages/shared-ux/error_boundary/src/ui/error_boundary.tsx b/packages/shared-ux/error_boundary/src/ui/error_boundary.tsx index 8e38a9e172f13..7fd601f65cfc1 100644 --- a/packages/shared-ux/error_boundary/src/ui/error_boundary.tsx +++ b/packages/shared-ux/error_boundary/src/ui/error_boundary.tsx @@ -42,6 +42,9 @@ class ErrorBoundaryInternal extends React.Component< } componentDidCatch(error: Error, errorInfo: React.ErrorInfo) { + console.error('Error caught by Kibana React Error Boundary'); // eslint-disable-line no-console + console.error(error); // eslint-disable-line no-console + const { name, isFatal } = this.props.services.errorService.registerError(error, errorInfo); this.setState(() => { return { error, errorInfo, componentName: name, isFatal };