diff --git a/packages/react-devtools-shared/src/backend/renderer.js b/packages/react-devtools-shared/src/backend/renderer.js index 9802d4b8c03d9..a123d96262c79 100644 --- a/packages/react-devtools-shared/src/backend/renderer.js +++ b/packages/react-devtools-shared/src/backend/renderer.js @@ -812,32 +812,28 @@ export function attach( // Patching the console enables DevTools to do a few useful things: // * Append component stacks to warnings and error messages // * Disable logging during re-renders to inspect hooks (see inspectHooksOfFiber) - // - // Don't patch in test environments because we don't want to interfere with Jest's own console overrides. - if (process.env.NODE_ENV !== 'test') { - registerRendererWithConsole(renderer, onErrorOrWarning); - - // The renderer interface can't read these preferences directly, - // because it is stored in localStorage within the context of the extension. - // It relies on the extension to pass the preference through via the global. - const appendComponentStack = - window.__REACT_DEVTOOLS_APPEND_COMPONENT_STACK__ !== false; - const breakOnConsoleErrors = - window.__REACT_DEVTOOLS_BREAK_ON_CONSOLE_ERRORS__ === true; - const showInlineWarningsAndErrors = - window.__REACT_DEVTOOLS_SHOW_INLINE_WARNINGS_AND_ERRORS__ !== false; - const hideConsoleLogsInStrictMode = - window.__REACT_DEVTOOLS_HIDE_CONSOLE_LOGS_IN_STRICT_MODE__ === true; - const browserTheme = window.__REACT_DEVTOOLS_BROWSER_THEME__; - - patchConsole({ - appendComponentStack, - breakOnConsoleErrors, - showInlineWarningsAndErrors, - hideConsoleLogsInStrictMode, - browserTheme, - }); - } + registerRendererWithConsole(renderer, onErrorOrWarning); + + // The renderer interface can't read these preferences directly, + // because it is stored in localStorage within the context of the extension. + // It relies on the extension to pass the preference through via the global. + const appendComponentStack = + window.__REACT_DEVTOOLS_APPEND_COMPONENT_STACK__ !== false; + const breakOnConsoleErrors = + window.__REACT_DEVTOOLS_BREAK_ON_CONSOLE_ERRORS__ === true; + const showInlineWarningsAndErrors = + window.__REACT_DEVTOOLS_SHOW_INLINE_WARNINGS_AND_ERRORS__ !== false; + const hideConsoleLogsInStrictMode = + window.__REACT_DEVTOOLS_HIDE_CONSOLE_LOGS_IN_STRICT_MODE__ === true; + const browserTheme = window.__REACT_DEVTOOLS_BROWSER_THEME__; + + patchConsole({ + appendComponentStack, + breakOnConsoleErrors, + showInlineWarningsAndErrors, + hideConsoleLogsInStrictMode, + browserTheme, + }); const debug = ( name: string,