From ba2e4a57e88ef226ae42c1830be758dca050c672 Mon Sep 17 00:00:00 2001 From: Tim Yung Date: Sun, 16 Jun 2024 10:30:39 -0700 Subject: [PATCH] RN: Migrate `LogBoxInspectorCodeFrame-test.js` from Shallow Renderer (#44979) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/44979 Migrates this Jest unit test away from using `react-shallow-renderer` because it is no longer recommended. Changelog: [Internal] Reviewed By: robhogan Differential Revision: D58643061 fbshipit-source-id: 0c68324d4d92fc8818ac469737eda3679aa773b3 --- .../LogBoxInspectorCodeFrame-test.js | 27 +++++++++++++++---- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/packages/react-native/Libraries/LogBox/UI/__tests__/LogBoxInspectorCodeFrame-test.js b/packages/react-native/Libraries/LogBox/UI/__tests__/LogBoxInspectorCodeFrame-test.js index 0d27cc4f5e3..7fd6c0872fb 100644 --- a/packages/react-native/Libraries/LogBox/UI/__tests__/LogBoxInspectorCodeFrame-test.js +++ b/packages/react-native/Libraries/LogBox/UI/__tests__/LogBoxInspectorCodeFrame-test.js @@ -15,17 +15,34 @@ const render = require('../../../../jest/renderer'); const LogBoxInspectorCodeFrame = require('../LogBoxInspectorCodeFrame').default; const React = require('react'); +// Mock child components because we are interested in snapshotting the behavior +// of `LogBoxInspectorCodeFrame`, not its children. +jest.mock('../../../Components/ScrollView/ScrollView', () => ({ + __esModule: true, + default: 'ScrollView', +})); +jest.mock('../AnsiHighlight', () => ({ + __esModule: true, + default: 'Ansi', +})); +jest.mock('../LogBoxButton', () => ({ + __esModule: true, + default: 'LogBoxButton', +})); +jest.mock('../LogBoxInspectorSection', () => ({ + __esModule: true, + default: 'LogBoxInspectorSection', +})); + describe('LogBoxInspectorCodeFrame', () => { it('should render null for no code frame', () => { - const output = render.shallowRender( - , - ); + const output = render.create(); expect(output).toMatchSnapshot(); }); it('should render a code frame', () => { - const output = render.shallowRender( + const output = render.create( { }); it('should render a code frame without a location', () => { - const output = render.shallowRender( + const output = render.create(