Don't hide console error|warn in inspectedElement-test (#24086)

This commit is contained in:
Sebastian Silbermann
2022-03-14 09:17:37 -04:00
committed by GitHub
parent 4cf9cf2414
commit 668babbbd0
@@ -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();
@@ -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'], () => {