From 2d3788678bc80dd08c5fbd1f07c6f118bd259f0d Mon Sep 17 00:00:00 2001 From: Tim Yung Date: Sat, 15 Jun 2024 17:41:43 -0700 Subject: [PATCH 1/2] RN: Migrate `LogBoxInspectorContainer-test.js` from Shallow Renderer Summary: Migrates this Jest unit test away from using `react-shallow-renderer` because it is no longer recommended. Changelog: [Internal] Differential Revision: D58641095 --- .../LogBoxInspectorContainer-test.js | 21 ++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/packages/react-native/Libraries/LogBox/__tests__/LogBoxInspectorContainer-test.js b/packages/react-native/Libraries/LogBox/__tests__/LogBoxInspectorContainer-test.js index 853954e6ebdf..8368411158f7 100644 --- a/packages/react-native/Libraries/LogBox/__tests__/LogBoxInspectorContainer-test.js +++ b/packages/react-native/Libraries/LogBox/__tests__/LogBoxInspectorContainer-test.js @@ -18,9 +18,16 @@ const { } = require('../LogBoxNotificationContainer'); const React = require('react'); +// Mock `LogBoxLogNotification` because we are interested in snapshotting the +// behavior of `LogBoxNotificationContainer`, not `LogBoxLogNotification`. +jest.mock('../UI/LogBoxNotification', () => ({ + __esModule: true, + default: 'LogBoxLogNotification', +})); + describe('LogBoxNotificationContainer', () => { it('should render null with no logs', () => { - const output = render.shallowRender( + const output = render.create( , ); @@ -28,7 +35,7 @@ describe('LogBoxNotificationContainer', () => { }); it('should render null with no selected log and disabled', () => { - const output = render.shallowRender( + const output = render.create( { }); it('should render the latest warning notification', () => { - const output = render.shallowRender( + const output = render.create( { }); it('should render the latest error notification', () => { - const output = render.shallowRender( + const output = render.create( { }); it('should render both an error and warning notification', () => { - const output = render.shallowRender( + const output = render.create( { }); it('should render selected fatal error even when disabled', () => { - const output = render.shallowRender( + const output = render.create( { }); it('should render selected syntax error even when disabled', () => { - const output = render.shallowRender( + const output = render.create( Date: Sat, 15 Jun 2024 19:12:16 -0700 Subject: [PATCH 2/2] '[skip ci] RN: Migrate from Shallow Renderer Summary: Migrates this Jest unit test away from using because it is no longer recommended. Changelog: [Internal] Differential Revision: D58641096 --- .../LogBoxInspectorMessageHeader-test.js | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/packages/react-native/Libraries/LogBox/UI/__tests__/LogBoxInspectorMessageHeader-test.js b/packages/react-native/Libraries/LogBox/UI/__tests__/LogBoxInspectorMessageHeader-test.js index 078f582015e2..287b185dae5f 100644 --- a/packages/react-native/Libraries/LogBox/UI/__tests__/LogBoxInspectorMessageHeader-test.js +++ b/packages/react-native/Libraries/LogBox/UI/__tests__/LogBoxInspectorMessageHeader-test.js @@ -16,9 +16,16 @@ const LogBoxInspectorMessageHeader = require('../LogBoxInspectorMessageHeader').default; const React = require('react'); +// Mock `LogBoxMessage` because we are interested in snapshotting the +// behavior of `LogBoxInspectorMessageHeader`, not `LogBoxMessage`. +jest.mock('../LogBoxMessage', () => ({ + __esModule: true, + default: 'LogBoxMessage', +})); + describe('LogBoxInspectorMessageHeader', () => { it('should render error', () => { - const output = render.shallowRender( + const output = render.create( { }); it('should render fatal', () => { - const output = render.shallowRender( + const output = render.create( { }); it('should render syntax error', () => { - const output = render.shallowRender( + const output = render.create( { }); it('should not render See More button for short content', () => { - const output = render.shallowRender( + const output = render.create( { }); it('should not render "See More" if expanded', () => { - const output = render.shallowRender( + const output = render.create( { }); it('should render "See More" if collapsed', () => { - const output = render.shallowRender( + const output = render.create(