diff --git a/packages/react-native/Libraries/LogBox/Data/LogBoxData.js b/packages/react-native/Libraries/LogBox/Data/LogBoxData.js index 367a78dd70db24..08c631c8fec2d8 100644 --- a/packages/react-native/Libraries/LogBox/Data/LogBoxData.js +++ b/packages/react-native/Libraries/LogBox/Data/LogBoxData.js @@ -82,9 +82,9 @@ let warningFilter: WarningFilter = function (format) { return { finalFormat: format, forceDialogImmediately: false, - suppressDialog_LEGACY: true, + suppressDialog_LEGACY: false, suppressCompletely: false, - monitorEvent: 'unknown', + monitorEvent: 'warning_unhandled', monitorListVersion: 0, monitorSampleRate: 1, }; diff --git a/packages/react-native/Libraries/LogBox/__tests__/LogBox-integration-test.js b/packages/react-native/Libraries/LogBox/__tests__/LogBox-integration-test.js index b6583f74a4a113..1e64e5e11efd8d 100644 --- a/packages/react-native/Libraries/LogBox/__tests__/LogBox-integration-test.js +++ b/packages/react-native/Libraries/LogBox/__tests__/LogBox-integration-test.js @@ -87,7 +87,7 @@ describe('LogBox', () => { expect.stringMatching('at DoesNotUseKey'), ]); expect(spy).toHaveBeenCalledWith({ - level: 'warn', + level: 'error', category: expect.stringContaining( 'Warning: Each child in a list should have a unique', ), @@ -140,7 +140,7 @@ describe('LogBox', () => { expect.stringMatching('at FragmentWithProp'), ]); expect(spy).toHaveBeenCalledWith({ - level: 'warn', + level: 'error', category: expect.stringContaining('Warning: Invalid prop'), componentStack: expect.anything(), componentStackType: expect.stringMatching(/(stack|legacy)/), @@ -236,7 +236,7 @@ describe('LogBox', () => { ), ]); expect(spy).toHaveBeenCalledWith({ - level: 'warn', + level: 'error', category: expect.stringContaining('Warning: Manual console error'), componentStack: expect.anything(), componentStackType: 'stack', diff --git a/packages/react-native/Libraries/LogBox/__tests__/LogBox-test.js b/packages/react-native/Libraries/LogBox/__tests__/LogBox-test.js index b44c6131ffb376..a8a40825354a1f 100644 --- a/packages/react-native/Libraries/LogBox/__tests__/LogBox-test.js +++ b/packages/react-native/Libraries/LogBox/__tests__/LogBox-test.js @@ -506,6 +506,45 @@ describe('LogBox', () => { 'Custom: after installing for the second time', ); }); + + it('registers errors with component stack as errors by default, when ExceptionManager is registered first', () => { + jest.spyOn(LogBoxData, 'checkWarningFilter'); + jest.spyOn(LogBoxData, 'addLog'); + + ExceptionsManager.installConsoleErrorReporter(); + LogBox.install(); + + console.error( + 'HIT\n at Text (/path/to/Component:30:175)\n at DoesNotUseKey', + ); + + expect(LogBoxData.addLog).toBeCalledWith( + expect.objectContaining({level: 'error'}), + ); + expect(LogBoxData.checkWarningFilter).toBeCalledWith( + 'HIT\n at Text (/path/to/Component:30:175)\n at DoesNotUseKey', + ); + }); + + it('registers errors with component stack as errors by default, when ExceptionManager is registered second', () => { + jest.spyOn(LogBoxData, 'checkWarningFilter'); + jest.spyOn(LogBoxData, 'addLog'); + + LogBox.install(); + ExceptionsManager.installConsoleErrorReporter(); + + console.error( + 'HIT\n at Text (/path/to/Component:30:175)\n at DoesNotUseKey', + ); + + expect(LogBoxData.addLog).toBeCalledWith( + expect.objectContaining({level: 'error'}), + ); + expect(LogBoxData.checkWarningFilter).toBeCalledWith( + 'HIT\n at Text (/path/to/Component:30:175)\n at DoesNotUseKey', + ); + }); + it('registers errors without component stack as errors by default, when ExceptionManager is registered first', () => { jest.spyOn(LogBoxData, 'checkWarningFilter'); jest.spyOn(LogBoxData, 'addException');