Skip to content

Commit

Permalink
Don't hide console error|warn in inspectedElement-test (#24086)
Browse files Browse the repository at this point in the history
  • Loading branch information
eps1lon authored Mar 14, 2022
1 parent 061ac27 commit 2bf7c02
Showing 1 changed file with 9 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ describe('InspectedElement', () => {
const prevInspectedElement = inspectedElement;

// This test causes an intermediate error to be logged but we can ignore it.
console.error = () => {};
jest.spyOn(console, 'error').mockImplementation(() => {});

// Wait for our check-for-updates poll to get the new data.
jest.runOnlyPendingTimers();
Expand Down Expand Up @@ -2804,16 +2804,18 @@ describe('InspectedElement', () => {
);

// Suppress expected error and warning.
const originalError = console.error;
const originalWarn = console.warn;
console.error = () => {};
console.warn = () => {};
const consoleErrorMock = jest
.spyOn(console, 'error')
.mockImplementation(() => {});
const consoleWarnMock = jest
.spyOn(console, 'warn')
.mockImplementation(() => {});

// now force error state on <Example />
await toggleError(true);

console.error = originalError;
console.warn = originalWarn;
consoleErrorMock.mockRestore();
consoleWarnMock.mockRestore();

// we are in error state now, <Example /> won't show up
withErrorsOrWarningsIgnored(['Invalid index'], () => {
Expand Down

0 comments on commit 2bf7c02

Please sign in to comment.