77 * @flow
88 */
99
10+ import {
11+ getLegacyRenderImplementation ,
12+ getModernRenderImplementation ,
13+ } from './utils' ;
14+
1015describe ( 'profiling HostRoot' , ( ) => {
1116 let React ;
12- let ReactDOMClient ;
1317 let Scheduler ;
14- let legacyRender ;
1518 let store ;
1619 let utils ;
1720 let getEffectDurations ;
@@ -22,14 +25,11 @@ describe('profiling HostRoot', () => {
2225 utils = require ( './utils' ) ;
2326 utils . beforeEachProfiling ( ) ;
2427
25- legacyRender = utils . legacyRender ;
26-
2728 getEffectDurations = require ( '../backend/utils' ) . getEffectDurations ;
2829
2930 store = global . store ;
3031
3132 React = require ( 'react' ) ;
32- ReactDOMClient = require ( 'react-dom/client' ) ;
3333 Scheduler = require ( 'scheduler' ) ;
3434
3535 effectDurations = [ ] ;
@@ -49,7 +49,11 @@ describe('profiling HostRoot', () => {
4949 } ;
5050 } ) ;
5151
52+ const { render : legacyRender } = getLegacyRenderImplementation ( ) ;
53+ const { render : modernRender } = getModernRenderImplementation ( ) ;
54+
5255 // @reactVersion >=18.0
56+ // @reactVersion < 19
5357 it ( 'should expose passive and layout effect durations for render()' , ( ) => {
5458 function App ( ) {
5559 React . useEffect ( ( ) => {
@@ -63,8 +67,7 @@ describe('profiling HostRoot', () => {
6367
6468 utils . act ( ( ) => store . profilerStore . startProfiling ( ) ) ;
6569 utils . act ( ( ) => {
66- const container = document . createElement ( 'div' ) ;
67- legacyRender ( < App /> , container ) ;
70+ legacyRender ( < App /> ) ;
6871 } ) ;
6972 utils . act ( ( ) => store . profilerStore . stopProfiling ( ) ) ;
7073
@@ -92,9 +95,7 @@ describe('profiling HostRoot', () => {
9295
9396 utils . act ( ( ) => store . profilerStore . startProfiling ( ) ) ;
9497 utils . act ( ( ) => {
95- const container = document . createElement ( 'div' ) ;
96- const root = ReactDOMClient . createRoot ( container ) ;
97- root . render ( < App /> ) ;
98+ modernRender ( < App /> ) ;
9899 } ) ;
99100 utils . act ( ( ) => store . profilerStore . stopProfiling ( ) ) ;
100101
@@ -126,12 +127,9 @@ describe('profiling HostRoot', () => {
126127 return null ;
127128 }
128129
129- const container = document . createElement ( 'div' ) ;
130- const root = ReactDOMClient . createRoot ( container ) ;
131-
132130 utils . act ( ( ) => store . profilerStore . startProfiling ( ) ) ;
133- utils . act ( ( ) => root . render ( < App /> ) ) ;
134- utils . act ( ( ) => root . render ( < App shouldCascade = { true } /> ) ) ;
131+ utils . act ( ( ) => modernRender ( < App /> ) ) ;
132+ utils . act ( ( ) => modernRender ( < App shouldCascade = { true } /> ) ) ;
135133 utils . act ( ( ) => store . profilerStore . stopProfiling ( ) ) ;
136134
137135 expect ( effectDurations ) . toHaveLength ( 3 ) ;
0 commit comments