From 479caa546b6e0c224da2dc850a73f621369399c2 Mon Sep 17 00:00:00 2001 From: Rob Hogan Date: Sun, 16 Jun 2024 12:49:38 -0700 Subject: [PATCH] Make jest/renderer `create` helper async in prep for concurrent Summary: Use our existing abstraction around `react-test-renderer`'s `create` and make it asynchronous, to allow for wrapping `create` in `act` in a subsequent diff, and using the async API per guidance in https://react.dev/reference/react/act?#await-act-async-actfn . Changelog: [Internal] Differential Revision: D58647827 --- .../__tests__/InputAccessoryView-test.js | 8 +-- .../__tests__/TouchableHighlight-test.js | 24 +++---- .../__tests__/TouchableNativeFeedback-test.js | 29 ++++----- .../Components/View/__tests__/View-test.js | 16 ++--- .../Libraries/Image/__tests__/Image-test.js | 12 ++-- .../Image/__tests__/ImageBackground-test.js | 12 ++-- .../LogBox/UI/__tests__/LogBoxButton-test.js | 8 +-- .../UI/__tests__/LogBoxInspector-test.js | 12 ++-- .../LogBoxInspectorCodeFrame-test.js | 14 ++-- .../__tests__/LogBoxInspectorFooter-test.js | 16 ++--- .../__tests__/LogBoxInspectorHeader-test.js | 16 ++--- .../LogBoxInspectorMessageHeader-test.js | 24 +++---- .../LogBoxInspectorReactFrames-test.js | 20 +++--- .../__tests__/LogBoxInspectorSection-test.js | 8 +-- .../LogBoxInspectorSourceMapStatus-test.js | 12 ++-- .../LogBoxInspectorStackFrame-test.js | 12 ++-- .../LogBoxInspectorStackFrames-test.js | 8 +-- .../LogBox/UI/__tests__/LogBoxMessage-test.js | 64 +++++++++---------- .../UI/__tests__/LogBoxNotification-test.js | 4 +- .../LogBoxInspectorContainer-test.js | 28 ++++---- .../LogBoxNotificationContainer-test.js | 4 +- .../Libraries/Modal/__tests__/Modal-test.js | 16 ++--- .../Libraries/Text/__tests__/Text-test.js | 16 ++--- packages/react-native/jest/renderer.js | 6 +- 24 files changed, 199 insertions(+), 190 deletions(-) diff --git a/packages/react-native/Libraries/Components/TextInput/__tests__/InputAccessoryView-test.js b/packages/react-native/Libraries/Components/TextInput/__tests__/InputAccessoryView-test.js index 97319e3e4937c0..b0bf085d517b3b 100644 --- a/packages/react-native/Libraries/Components/TextInput/__tests__/InputAccessoryView-test.js +++ b/packages/react-native/Libraries/Components/TextInput/__tests__/InputAccessoryView-test.js @@ -17,8 +17,8 @@ const InputAccessoryView = require('../InputAccessoryView').default; const React = require('react'); describe('InputAccessoryView', () => { - it('should render as when mocked', () => { - const instance = render.create( + it('should render as when mocked', async () => { + const instance = await render.create( , @@ -26,10 +26,10 @@ describe('InputAccessoryView', () => { expect(instance).toMatchSnapshot(); }); - it('should render as when not mocked', () => { + it('should render as when not mocked', async () => { jest.dontMock('../InputAccessoryView'); - const instance = render.create( + const instance = await render.create( , diff --git a/packages/react-native/Libraries/Components/Touchable/__tests__/TouchableHighlight-test.js b/packages/react-native/Libraries/Components/Touchable/__tests__/TouchableHighlight-test.js index 024feffaa29260..fef49ff393b1e6 100644 --- a/packages/react-native/Libraries/Components/Touchable/__tests__/TouchableHighlight-test.js +++ b/packages/react-native/Libraries/Components/Touchable/__tests__/TouchableHighlight-test.js @@ -18,8 +18,8 @@ import * as React from 'react'; const render = require('../../../../jest/renderer'); describe('TouchableHighlight', () => { - it('renders correctly', () => { - const instance = render.create( + it('renders correctly', async () => { + const instance = await render.create( Touchable , @@ -34,9 +34,9 @@ describe('TouchableHighlight', () => { }); describe('TouchableHighlight with disabled state', () => { - it('should be disabled when disabled is true', () => { + it('should be disabled when disabled is true', async () => { expect( - render.create( + await render.create( , @@ -44,9 +44,9 @@ describe('TouchableHighlight with disabled state', () => { ).toMatchSnapshot(); }); - it('should be disabled when disabled is true and accessibilityState is empty', () => { + it('should be disabled when disabled is true and accessibilityState is empty', async () => { expect( - render.create( + await render.create( , @@ -54,9 +54,9 @@ describe('TouchableHighlight with disabled state', () => { ).toMatchSnapshot(); }); - it('should keep accessibilityState when disabled is true', () => { + it('should keep accessibilityState when disabled is true', async () => { expect( - render.create( + await render.create( @@ -66,9 +66,9 @@ describe('TouchableHighlight with disabled state', () => { ).toMatchSnapshot(); }); - it('should overwrite accessibilityState with value of disabled prop', () => { + it('should overwrite accessibilityState with value of disabled prop', async () => { expect( - render.create( + await render.create( @@ -78,9 +78,9 @@ describe('TouchableHighlight with disabled state', () => { ).toMatchSnapshot(); }); - it('should disable button when accessibilityState is disabled', () => { + it('should disable button when accessibilityState is disabled', async () => { expect( - render.create( + await render.create( , diff --git a/packages/react-native/Libraries/Components/Touchable/__tests__/TouchableNativeFeedback-test.js b/packages/react-native/Libraries/Components/Touchable/__tests__/TouchableNativeFeedback-test.js index 377c4f373764d7..d12331c3356a8a 100644 --- a/packages/react-native/Libraries/Components/Touchable/__tests__/TouchableNativeFeedback-test.js +++ b/packages/react-native/Libraries/Components/Touchable/__tests__/TouchableNativeFeedback-test.js @@ -14,13 +14,12 @@ import Text from '../../../Text/Text'; import View from '../../View/View'; import TouchableNativeFeedback from '../TouchableNativeFeedback'; import * as React from 'react'; -import ReactTestRenderer from 'react-test-renderer'; const render = require('../../../../jest/renderer'); describe('TouchableWithoutFeedback', () => { - it('renders correctly', () => { - const instance = render.create( + it('renders correctly', async () => { + const instance = await render.create( Touchable , @@ -37,8 +36,8 @@ describe('TouchableWithoutFeedback', () => { }); describe('', () => { - it('should render as expected', () => { - const instance = ReactTestRenderer.create( + it('should render as expected', async () => { + const instance = await render.create( , @@ -49,9 +48,9 @@ describe('', () => { }); describe('', () => { - it('should be disabled when disabled is true', () => { + it('should be disabled when disabled is true', async () => { expect( - ReactTestRenderer.create( + await render.create( , @@ -61,9 +60,9 @@ describe('', () => { }); describe('', () => { - it('should be disabled when disabled is true and accessibilityState is empty', () => { + it('should be disabled when disabled is true and accessibilityState is empty', async () => { expect( - ReactTestRenderer.create( + await render.create( , @@ -73,9 +72,9 @@ describe('', () }); describe('', () => { - it('should keep accessibilityState when disabled is true', () => { + it('should keep accessibilityState when disabled is true', async () => { expect( - ReactTestRenderer.create( + await render.create( @@ -87,9 +86,9 @@ describe('', () => { - it('should overwrite accessibilityState with value of disabled prop', () => { + it('should overwrite accessibilityState with value of disabled prop', async () => { expect( - ReactTestRenderer.create( + await render.create( @@ -101,9 +100,9 @@ describe('', () => { - it('should overwrite accessibilityState with value of disabled prop', () => { + it('should overwrite accessibilityState with value of disabled prop', async () => { expect( - ReactTestRenderer.create( + await render.create( diff --git a/packages/react-native/Libraries/Components/View/__tests__/View-test.js b/packages/react-native/Libraries/Components/View/__tests__/View-test.js index cf9be9fffe8356..1102acc61ca23c 100644 --- a/packages/react-native/Libraries/Components/View/__tests__/View-test.js +++ b/packages/react-native/Libraries/Components/View/__tests__/View-test.js @@ -18,8 +18,8 @@ jest.unmock('../View'); jest.unmock('../ViewNativeComponent'); describe('View', () => { - it('default render', () => { - const instance = render.create(); + it('default render', async () => { + const instance = await render.create(); expect(instance.toJSON()).toMatchInlineSnapshot(``); }); @@ -30,14 +30,14 @@ describe('View', () => { }); describe('View compat with web', () => { - it('renders core props', () => { + it('renders core props', async () => { const props = { id: 'id', tabIndex: 0, testID: 'testID', }; - const instance = render.create(); + const instance = await render.create(); expect(instance.toJSON()).toMatchInlineSnapshot(` { `); }); - it('renders "aria-*" props', () => { + it('renders "aria-*" props', async () => { const props = { 'aria-activedescendant': 'activedescendant', 'aria-atomic': true, @@ -98,7 +98,7 @@ describe('View compat with web', () => { 'aria-valuetext': '3', }; - const instance = render.create(); + const instance = await render.create(); expect(instance.toJSON()).toMatchInlineSnapshot(` { `); }); - it('renders styles', () => { + it('renders styles', async () => { const style = { display: 'flex', flex: 1, @@ -174,7 +174,7 @@ describe('View compat with web', () => { pointerEvents: 'none', }; - const instance = render.create(); + const instance = await render.create(); expect(instance.toJSON()).toMatchInlineSnapshot(` { - it('should render as when mocked', () => { - const instance = render.create(); + it('should render as when mocked', async () => { + const instance = await render.create( + , + ); expect(instance).toMatchSnapshot(); }); - it('should render as when not mocked', () => { + it('should render as when not mocked', async () => { jest.dontMock('../Image'); - const instance = render.create(); + const instance = await render.create( + , + ); expect(instance).toMatchSnapshot(); }); diff --git a/packages/react-native/Libraries/Image/__tests__/ImageBackground-test.js b/packages/react-native/Libraries/Image/__tests__/ImageBackground-test.js index 473372c11e6fc5..d13158dc9ae7c0 100644 --- a/packages/react-native/Libraries/Image/__tests__/ImageBackground-test.js +++ b/packages/react-native/Libraries/Image/__tests__/ImageBackground-test.js @@ -16,8 +16,8 @@ const ImageBackground = require('../ImageBackground'); const React = require('react'); describe('ImageBackground', () => { - it('should render as when mocked', () => { - const instance = render.create( + it('should render as when mocked', async () => { + const instance = await render.create( { expect(instance).toMatchSnapshot(); }); - it('should render as when not mocked', () => { + it('should render as when not mocked', async () => { jest.dontMock('../ImageBackground'); - const instance = render.create( + const instance = await render.create( { expect(instance).toMatchSnapshot(); }); - it('should be set importantForAccessibility in and ', () => { - const instance = render.create( + it('should be set importantForAccessibility in and ', async () => { + const instance = await render.create( ({ })); describe('LogBoxButton', () => { - it('should render only a view without an onPress', () => { - const output = render.create( + it('should render only a view without an onPress', async () => { + const output = await render.create( { expect(output).toMatchSnapshot(); }); - it('should render TouchableWithoutFeedback and pass through props', () => { - const output = render.create( + it('should render TouchableWithoutFeedback and pass through props', async () => { + const output = await render.create( { - it('should render null with no logs', () => { - const output = render.create( + it('should render null with no logs', async () => { + const output = await render.create( {}} onMinimize={() => {}} @@ -82,8 +82,8 @@ describe('LogBoxContainer', () => { expect(output).toMatchSnapshot(); }); - it('should render warning with selectedIndex 0', () => { - const output = render.create( + it('should render warning with selectedIndex 0', async () => { + const output = await render.create( {}} onMinimize={() => {}} @@ -96,8 +96,8 @@ describe('LogBoxContainer', () => { expect(output).toMatchSnapshot(); }); - it('should render fatal with selectedIndex 2', () => { - const output = render.create( + it('should render fatal with selectedIndex 2', async () => { + const output = await render.create( {}} onMinimize={() => {}} 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 7fd6c0872fb504..302fb4508b08f2 100644 --- a/packages/react-native/Libraries/LogBox/UI/__tests__/LogBoxInspectorCodeFrame-test.js +++ b/packages/react-native/Libraries/LogBox/UI/__tests__/LogBoxInspectorCodeFrame-test.js @@ -35,14 +35,16 @@ jest.mock('../LogBoxInspectorSection', () => ({ })); describe('LogBoxInspectorCodeFrame', () => { - it('should render null for no code frame', () => { - const output = render.create(); + it('should render null for no code frame', async () => { + const output = await render.create( + , + ); expect(output).toMatchSnapshot(); }); - it('should render a code frame', () => { - const output = render.create( + it('should render a code frame', async () => { + const output = await render.create( { expect(output).toMatchSnapshot(); }); - it('should render a code frame without a location', () => { - const output = render.create( + it('should render a code frame without a location', async () => { + const output = await render.create( ({ })); describe('LogBoxInspectorFooter', () => { - it('should render two buttons for warning', () => { - const output = render.create( + it('should render two buttons for warning', async () => { + const output = await render.create( {}} onDismiss={() => {}} @@ -35,8 +35,8 @@ describe('LogBoxInspectorFooter', () => { expect(output).toMatchSnapshot(); }); - it('should render two buttons for error', () => { - const output = render.create( + it('should render two buttons for error', async () => { + const output = await render.create( {}} onDismiss={() => {}} @@ -47,8 +47,8 @@ describe('LogBoxInspectorFooter', () => { expect(output).toMatchSnapshot(); }); - it('should render two buttons for fatal', () => { - const output = render.create( + it('should render two buttons for fatal', async () => { + const output = await render.create( {}} onDismiss={() => {}} @@ -59,8 +59,8 @@ describe('LogBoxInspectorFooter', () => { expect(output).toMatchSnapshot(); }); - it('should render no buttons and a message for syntax error', () => { - const output = render.create( + it('should render no buttons and a message for syntax error', async () => { + const output = await render.create( {}} onDismiss={() => {}} diff --git a/packages/react-native/Libraries/LogBox/UI/__tests__/LogBoxInspectorHeader-test.js b/packages/react-native/Libraries/LogBox/UI/__tests__/LogBoxInspectorHeader-test.js index a16f1474b56c21..6cc3770fccaba0 100644 --- a/packages/react-native/Libraries/LogBox/UI/__tests__/LogBoxInspectorHeader-test.js +++ b/packages/react-native/Libraries/LogBox/UI/__tests__/LogBoxInspectorHeader-test.js @@ -23,8 +23,8 @@ jest.mock('../LogBoxInspectorHeaderButton', () => ({ })); describe('LogBoxInspectorHeader', () => { - it('should render no buttons for one total', () => { - const output = render.create( + it('should render no buttons for one total', async () => { + const output = await render.create( {}} selectedIndex={0} @@ -36,8 +36,8 @@ describe('LogBoxInspectorHeader', () => { expect(output).toMatchSnapshot(); }); - it('should render both buttons for two total', () => { - const output = render.create( + it('should render both buttons for two total', async () => { + const output = await render.create( {}} selectedIndex={1} @@ -49,8 +49,8 @@ describe('LogBoxInspectorHeader', () => { expect(output).toMatchSnapshot(); }); - it('should render two buttons for three or more total', () => { - const output = render.create( + it('should render two buttons for three or more total', async () => { + const output = await render.create( {}} selectedIndex={0} @@ -62,8 +62,8 @@ describe('LogBoxInspectorHeader', () => { expect(output).toMatchSnapshot(); }); - it('should render syntax error header', () => { - const output = render.create( + it('should render syntax error header', async () => { + const output = await render.create( {}} selectedIndex={0} 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 287b185dae5fe5..2f55614f05a3ea 100644 --- a/packages/react-native/Libraries/LogBox/UI/__tests__/LogBoxInspectorMessageHeader-test.js +++ b/packages/react-native/Libraries/LogBox/UI/__tests__/LogBoxInspectorMessageHeader-test.js @@ -24,8 +24,8 @@ jest.mock('../LogBoxMessage', () => ({ })); describe('LogBoxInspectorMessageHeader', () => { - it('should render error', () => { - const output = render.create( + it('should render error', async () => { + const output = await render.create( { expect(output).toMatchSnapshot(); }); - it('should render fatal', () => { - const output = render.create( + it('should render fatal', async () => { + const output = await render.create( { expect(output).toMatchSnapshot(); }); - it('should render syntax error', () => { - const output = render.create( + it('should render syntax error', async () => { + const output = await render.create( { expect(output).toMatchSnapshot(); }); - it('should not render See More button for short content', () => { - const output = render.create( + it('should not render See More button for short content', async () => { + const output = await render.create( { expect(output).toMatchSnapshot(); }); - it('should not render "See More" if expanded', () => { - const output = render.create( + it('should not render "See More" if expanded', async () => { + const output = await render.create( { expect(output).toMatchSnapshot(); }); - it('should render "See More" if collapsed', () => { - const output = render.create( + it('should render "See More" if collapsed', async () => { + const output = await render.create( ({ })); describe('LogBoxInspectorReactFrames', () => { - it('should render null for no componentStack frames', () => { - const output = render.create( + it('should render null for no componentStack frames', async () => { + const output = await render.create( { expect(output).toMatchSnapshot(); }); - it('should render componentStack frames without full path pressable', () => { - const output = render.create( + it('should render componentStack frames without full path pressable', async () => { + const output = await render.create( { expect(output).toMatchSnapshot(); }); - it('should render componentStack frames with full path pressable', () => { - const output = render.create( + it('should render componentStack frames with full path pressable', async () => { + const output = await render.create( { expect(output).toMatchSnapshot(); }); - it('should render componentStack frames with parent folder of index.js', () => { - const output = render.create( + it('should render componentStack frames with parent folder of index.js', async () => { + const output = await render.create( { expect(output).toMatchSnapshot(); }); - it('should render componentStack frames with more than 3 stacks', () => { - const output = render.create( + it('should render componentStack frames with more than 3 stacks', async () => { + const output = await render.create( { - it('should render with only heading', () => { - const output = render.create( + it('should render with only heading', async () => { + const output = await render.create( Child , @@ -26,8 +26,8 @@ describe('LogBoxInspectorSection', () => { expect(output).toMatchSnapshot(); }); - it('should render with action on the right', () => { - const output = render.create( + it('should render with action on the right', async () => { + const output = await render.create( Right}> diff --git a/packages/react-native/Libraries/LogBox/UI/__tests__/LogBoxInspectorSourceMapStatus-test.js b/packages/react-native/Libraries/LogBox/UI/__tests__/LogBoxInspectorSourceMapStatus-test.js index f9ca446de360de..44855457851a96 100644 --- a/packages/react-native/Libraries/LogBox/UI/__tests__/LogBoxInspectorSourceMapStatus-test.js +++ b/packages/react-native/Libraries/LogBox/UI/__tests__/LogBoxInspectorSourceMapStatus-test.js @@ -24,24 +24,24 @@ jest.mock('../LogBoxButton', () => ({ })); describe('LogBoxInspectorSourceMapStatus', () => { - it('should render for failed', () => { - const output = render.create( + it('should render for failed', async () => { + const output = await render.create( {}} status="FAILED" />, ); expect(output).toMatchSnapshot(); }); - it('should render for pending', () => { - const output = render.create( + it('should render for pending', async () => { + const output = await render.create( {}} status="PENDING" />, ); expect(output).toMatchSnapshot(); }); - it('should render null for complete', () => { - const output = render.create( + it('should render null for complete', async () => { + const output = await render.create( {}} status="COMPLETE" />, ); diff --git a/packages/react-native/Libraries/LogBox/UI/__tests__/LogBoxInspectorStackFrame-test.js b/packages/react-native/Libraries/LogBox/UI/__tests__/LogBoxInspectorStackFrame-test.js index b853ee23170612..1e66b1b380e5d0 100644 --- a/packages/react-native/Libraries/LogBox/UI/__tests__/LogBoxInspectorStackFrame-test.js +++ b/packages/react-native/Libraries/LogBox/UI/__tests__/LogBoxInspectorStackFrame-test.js @@ -24,8 +24,8 @@ jest.mock('../LogBoxButton', () => ({ })); describe('LogBoxInspectorStackFrame', () => { - it('should render stack frame', () => { - const output = render.create( + it('should render stack frame', async () => { + const output = await render.create( {}} frame={{ @@ -41,8 +41,8 @@ describe('LogBoxInspectorStackFrame', () => { expect(output).toMatchSnapshot(); }); - it('should render stack frame without press feedback', () => { - const output = render.create( + it('should render stack frame without press feedback', async () => { + const output = await render.create( { expect(output).toMatchSnapshot(); }); - it('should render collapsed stack frame with dimmed text', () => { - const output = render.create( + it('should render collapsed stack frame with dimmed text', async () => { + const output = await render.create( {}} frame={{ diff --git a/packages/react-native/Libraries/LogBox/UI/__tests__/LogBoxInspectorStackFrames-test.js b/packages/react-native/Libraries/LogBox/UI/__tests__/LogBoxInspectorStackFrames-test.js index a8d648692c98b8..712a9c1a9dd639 100644 --- a/packages/react-native/Libraries/LogBox/UI/__tests__/LogBoxInspectorStackFrames-test.js +++ b/packages/react-native/Libraries/LogBox/UI/__tests__/LogBoxInspectorStackFrames-test.js @@ -51,8 +51,8 @@ const createCollapsedFrames = (collapsedOptions: Array) => { }; describe('LogBoxInspectorStackFrames', () => { - it('should render stack frames with 1 frame collapsed', () => { - const output = render.create( + it('should render stack frames with 1 frame collapsed', async () => { + const output = await render.create( {}} log={createLogWithFrames([false, true])} @@ -62,8 +62,8 @@ describe('LogBoxInspectorStackFrames', () => { expect(output).toMatchSnapshot(); }); - it('should render null for empty stack frames', () => { - const output = render.create( + it('should render null for empty stack frames', async () => { + const output = await render.create( {}} log={createLogWithFrames([])} diff --git a/packages/react-native/Libraries/LogBox/UI/__tests__/LogBoxMessage-test.js b/packages/react-native/Libraries/LogBox/UI/__tests__/LogBoxMessage-test.js index 978832d08df389..955423aa3c423a 100644 --- a/packages/react-native/Libraries/LogBox/UI/__tests__/LogBoxMessage-test.js +++ b/packages/react-native/Libraries/LogBox/UI/__tests__/LogBoxMessage-test.js @@ -16,8 +16,8 @@ const LogBoxMessage = require('../LogBoxMessage').default; const React = require('react'); describe('LogBoxMessage', () => { - it('should render message', () => { - const output = render.create( + it('should render message', async () => { + const output = await render.create( { expect(output).toMatchSnapshot(); }); - it('should render message truncated to 6 chars', () => { - const output = render.create( + it('should render message truncated to 6 chars', async () => { + const output = await render.create( { expect(output).toMatchSnapshot(); }); - it('should render the whole message when maxLength = message length', () => { + it('should render the whole message when maxLength = message length', async () => { const message = 'Some kind of message'; - const output = render.create( + const output = await render.create( { expect(output).toMatchSnapshot(); }); - it('should render message with substitution', () => { - const output = render.create( + it('should render message with substitution', async () => { + const output = await render.create( { expect(output).toMatchSnapshot(); }); - it('should render message with substitution, truncating the first word 3 letters in', () => { - const output = render.create( + it('should render message with substitution, truncating the first word 3 letters in', async () => { + const output = await render.create( { expect(output).toMatchSnapshot(); }); - it('should render message with substitution, truncating the second word 6 letters in', () => { - const output = render.create( + it('should render message with substitution, truncating the second word 6 letters in', async () => { + const output = await render.create( { expect(output).toMatchSnapshot(); }); - it('should render message with substitution, truncating the third word 2 letters in', () => { - const output = render.create( + it('should render message with substitution, truncating the third word 2 letters in', async () => { + const output = await render.create( { expect(output).toMatchSnapshot(); }); - it('should render the whole message with substitutions when maxLength = message length', () => { + it('should render the whole message with substitutions when maxLength = message length', async () => { const message = 'normal substitution normal'; - const output = render.create( + const output = await render.create( { expect(output).toMatchSnapshot(); }); - it('should render a plaintext message with no substitutions', () => { - const output = render.create( + it('should render a plaintext message with no substitutions', async () => { + const output = await render.create( { expect(output).toMatchSnapshot(); }); - it('should render a plaintext message and clean the content', () => { - const output = render.create( + it('should render a plaintext message and clean the content', async () => { + const output = await render.create( { expect(output).toMatchSnapshot(); }); - it('Should strip "TransformError " without breaking substitution', () => { - const output = render.create( + it('Should strip "TransformError " without breaking substitution', async () => { + const output = await render.create( { expect(output).toMatchSnapshot(); }); - it('Should strip "Warning: " without breaking substitution', () => { - const output = render.create( + it('Should strip "Warning: " without breaking substitution', async () => { + const output = await render.create( { expect(output).toMatchSnapshot(); }); - it('Should strip "Warning: Warning: " without breaking substitution', () => { - const output = render.create( + it('Should strip "Warning: Warning: " without breaking substitution', async () => { + const output = await render.create( { expect(output).toMatchSnapshot(); }); - it('Should make links tappable', () => { - const output = render.create( + it('Should make links tappable', async () => { + const output = await render.create( { expect(output).toMatchSnapshot(); }); - it('Should handle multiple links', () => { - const output = render.create( + it('Should handle multiple links', async () => { + const output = await render.create( { expect(output).toMatchSnapshot(); }); - it('Should handle truncated links', () => { - const output = render.create( + it('Should handle truncated links', async () => { + const output = await render.create( { - it('should render log', () => { - const output = render.create( + it('should render log', async () => { + const output = await render.create( ({ })); describe('LogBoxNotificationContainer', () => { - it('should render null with no logs', () => { - const output = render.create( + it('should render null with no logs', async () => { + const output = await render.create( , ); expect(output).toMatchSnapshot(); }); - it('should render null with no selected log and disabled', () => { - const output = render.create( + it('should render null with no selected log and disabled', async () => { + const output = await render.create( { expect(output).toMatchSnapshot(); }); - it('should render the latest warning notification', () => { - const output = render.create( + it('should render the latest warning notification', async () => { + const output = await render.create( { expect(output).toMatchSnapshot(); }); - it('should render the latest error notification', () => { - const output = render.create( + it('should render the latest error notification', async () => { + const output = await render.create( { expect(output).toMatchSnapshot(); }); - it('should render both an error and warning notification', () => { - const output = render.create( + it('should render both an error and warning notification', async () => { + const output = await render.create( { expect(output).toMatchSnapshot(); }); - it('should render selected fatal error even when disabled', () => { - const output = render.create( + it('should render selected fatal error even when disabled', async () => { + const output = await render.create( { expect(output).toMatchSnapshot(); }); - it('should render selected syntax error even when disabled', () => { - const output = render.create( + it('should render selected syntax error even when disabled', async () => { + const output = await render.create( ({ })); describe('LogBoxNotificationContainer', () => { - it('should render inspector with logs, even when disabled', () => { - const output = render.create( + it('should render inspector with logs, even when disabled', async () => { + const output = await render.create( { - it('should render as when mocked', () => { - const instance = render.create( + it('should render as when mocked', async () => { + const instance = await render.create( , @@ -26,8 +26,8 @@ describe('Modal', () => { expect(instance).toMatchSnapshot(); }); - it('should not render when mocked with visible=false', () => { - const instance = render.create( + it('should not render when mocked with visible=false', async () => { + const instance = await render.create( , @@ -35,10 +35,10 @@ describe('Modal', () => { expect(instance.toJSON()).toBeNull(); }); - it('should render as when not mocked', () => { + it('should render as when not mocked', async () => { jest.dontMock('../Modal'); - const instance = render.create( + const instance = await render.create( , @@ -46,10 +46,10 @@ describe('Modal', () => { expect(instance).toMatchSnapshot(); }); - it('should not render when not mocked with visible=false', () => { + it('should not render when not mocked with visible=false', async () => { jest.dontMock('../Modal'); - const instance = render.create( + const instance = await render.create( , diff --git a/packages/react-native/Libraries/Text/__tests__/Text-test.js b/packages/react-native/Libraries/Text/__tests__/Text-test.js index 60a5381c9f247a..6e3f1923eed0e5 100644 --- a/packages/react-native/Libraries/Text/__tests__/Text-test.js +++ b/packages/react-native/Libraries/Text/__tests__/Text-test.js @@ -24,8 +24,8 @@ function omitRef(json) { } describe('Text', () => { - it('default render', () => { - const instance = render.create(); + it('default render', async () => { + const instance = await render.create(); expect(omitRef(instance.toJSON())).toMatchInlineSnapshot(` { }); describe('Text compat with web', () => { - it('renders core props', () => { + it('renders core props', async () => { const props = { id: 'id', tabIndex: 0, testID: 'testID', }; - const instance = render.create(); + const instance = await render.create(); expect(omitRef(instance.toJSON())).toMatchInlineSnapshot(` { `); }); - it('renders "aria-*" props', () => { + it('renders "aria-*" props', async () => { const props = { 'aria-activedescendant': 'activedescendant', 'aria-atomic': true, @@ -117,7 +117,7 @@ describe('Text compat with web', () => { 'aria-valuetext': '3', }; - const instance = render.create(); + const instance = await render.create(); expect(omitRef(instance.toJSON())).toMatchInlineSnapshot(` { `); }); - it('renders styles', () => { + it('renders styles', async () => { const style = { display: 'flex', flex: 1, @@ -191,7 +191,7 @@ describe('Text compat with web', () => { verticalAlign: 'middle', }; - const instance = render.create(); + const instance = await render.create(); expect(omitRef(instance.toJSON())).toMatchInlineSnapshot(` ): any => { +export const create = async ( + Component: React.Element, +): Promise => { return TestRenderer.create(Component); };