@@ -459,7 +459,7 @@ describe('InspectedElement', () => {
459
459
const prevInspectedElement = inspectedElement ;
460
460
461
461
// This test causes an intermediate error to be logged but we can ignore it.
462
- console . error = ( ) => { } ;
462
+ jest . spyOn ( console , 'error' ) . mockImplementation ( ( ) => { } ) ;
463
463
464
464
// Wait for our check-for-updates poll to get the new data.
465
465
jest . runOnlyPendingTimers ( ) ;
@@ -2804,16 +2804,18 @@ describe('InspectedElement', () => {
2804
2804
) ;
2805
2805
2806
2806
// Suppress expected error and warning.
2807
- const originalError = console . error ;
2808
- const originalWarn = console . warn ;
2809
- console . error = ( ) => { } ;
2810
- console . warn = ( ) => { } ;
2807
+ const consoleErrorMock = jest
2808
+ . spyOn ( console , 'error' )
2809
+ . mockImplementation ( ( ) => { } ) ;
2810
+ const consoleWarnMock = jest
2811
+ . spyOn ( console , 'warn' )
2812
+ . mockImplementation ( ( ) => { } ) ;
2811
2813
2812
2814
// now force error state on <Example />
2813
2815
await toggleError ( true ) ;
2814
2816
2815
- console . error = originalError ;
2816
- console . warn = originalWarn ;
2817
+ consoleErrorMock . mockRestore ( ) ;
2818
+ consoleWarnMock . mockRestore ( ) ;
2817
2819
2818
2820
// we are in error state now, <Example /> won't show up
2819
2821
withErrorsOrWarningsIgnored ( [ 'Invalid index' ] , ( ) => {
0 commit comments