Wrap jest/renderer create abstraction in act for concurrent rendering (#44994)

Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/44994

For RN monorepo tests, wrap `create` calls through our `jest/renderer` abstraction in `await act`.

This is a no-op under current React but will be required under `react-test-renderer@19` with `IS_REACT_ACT_ENVIRONMENT`.

Changelog: [Internal]

Reviewed By: yungsters

Differential Revision: D58650940

fbshipit-source-id: 4013af89dd7c9f447b2dd493989f3a4fdf2b6508
This commit is contained in:
Rob Hogan
2024-06-16 16:55:21 -07:00
committed by Facebook GitHub Bot
parent 84866617de
commit 132e2a305c
2 changed files with 11 additions and 1 deletions
@@ -101,6 +101,11 @@ exports[`LogBoxInspectorSourceMapStatus should render for pending 1`] = `
"height": 14,
"marginEnd": 4,
"tintColor": "rgba(250, 186, 48, 1)",
"transform": Array [
Object {
"rotate": "0deg",
},
],
"width": 16,
}
}
+6 -1
View File
@@ -11,11 +11,16 @@
import type {ReactTestRenderer} from 'react-test-renderer';
import nullthrows from 'nullthrows';
import * as React from 'react';
import TestRenderer from 'react-test-renderer';
export async function create(
Component: React.Element<any>,
): Promise<ReactTestRenderer> {
return TestRenderer.create(Component);
let component;
await TestRenderer.act(async () => {
component = TestRenderer.create(Component);
});
return nullthrows(component);
}