mirror of
https://github.com/hanzoai/react.git
synced 2026-09-24 17:02:27 +00:00
Don't hide console error|warn in inspectedElement-test (#24086)
This commit is contained in:
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'], () => {
|
||||
|
||||
Reference in New Issue
Block a user