Chore: Remove console output in ErrorBoundary.test.tsx (#45138)

This commit is contained in:
Hugo Häggmark 2022-02-09 13:45:36 +01:00 committed by GitHub
parent 605d056136
commit 0282d5f9c3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -9,7 +9,18 @@ const ErrorThrower: FC<{ error: Error }> = ({ error }) => {
throw error;
};
// According to this issue https://github.com/facebook/react/issues/15069 componentDidCatch logs errors to console.error unconditionally.
// Let's make sure we don't output that to console.error in the tests.
let consoleSpy: jest.SpyInstance;
describe('ErrorBoundary', () => {
beforeEach(() => {
consoleSpy = jest.spyOn(console, 'error').mockImplementation(() => {});
});
afterEach(() => {
consoleSpy.mockRestore();
});
it('should catch error and report it to sentry, including react component stack in context', async () => {
const problem = new Error('things went terribly wrong');
render(