7
7
* @flow
8
8
*/
9
9
10
+ import {
11
+ getLegacyRenderImplementation ,
12
+ getModernRenderImplementation ,
13
+ } from './utils' ;
14
+
10
15
describe ( 'profiling HostRoot' , ( ) => {
11
16
let React ;
12
- let ReactDOMClient ;
13
17
let Scheduler ;
14
- let legacyRender ;
15
18
let store ;
16
19
let utils ;
17
20
let getEffectDurations ;
@@ -22,14 +25,11 @@ describe('profiling HostRoot', () => {
22
25
utils = require ( './utils' ) ;
23
26
utils . beforeEachProfiling ( ) ;
24
27
25
- legacyRender = utils . legacyRender ;
26
-
27
28
getEffectDurations = require ( '../backend/utils' ) . getEffectDurations ;
28
29
29
30
store = global . store ;
30
31
31
32
React = require ( 'react' ) ;
32
- ReactDOMClient = require ( 'react-dom/client' ) ;
33
33
Scheduler = require ( 'scheduler' ) ;
34
34
35
35
effectDurations = [ ] ;
@@ -49,7 +49,11 @@ describe('profiling HostRoot', () => {
49
49
} ;
50
50
} ) ;
51
51
52
+ const { render : legacyRender } = getLegacyRenderImplementation ( ) ;
53
+ const { render : modernRender } = getModernRenderImplementation ( ) ;
54
+
52
55
// @reactVersion >=18.0
56
+ // @reactVersion < 19
53
57
it ( 'should expose passive and layout effect durations for render()' , ( ) => {
54
58
function App ( ) {
55
59
React . useEffect ( ( ) => {
@@ -63,8 +67,7 @@ describe('profiling HostRoot', () => {
63
67
64
68
utils . act ( ( ) => store . profilerStore . startProfiling ( ) ) ;
65
69
utils . act ( ( ) => {
66
- const container = document . createElement ( 'div' ) ;
67
- legacyRender ( < App /> , container ) ;
70
+ legacyRender ( < App /> ) ;
68
71
} ) ;
69
72
utils . act ( ( ) => store . profilerStore . stopProfiling ( ) ) ;
70
73
@@ -92,9 +95,7 @@ describe('profiling HostRoot', () => {
92
95
93
96
utils . act ( ( ) => store . profilerStore . startProfiling ( ) ) ;
94
97
utils . act ( ( ) => {
95
- const container = document . createElement ( 'div' ) ;
96
- const root = ReactDOMClient . createRoot ( container ) ;
97
- root . render ( < App /> ) ;
98
+ modernRender ( < App /> ) ;
98
99
} ) ;
99
100
utils . act ( ( ) => store . profilerStore . stopProfiling ( ) ) ;
100
101
@@ -126,12 +127,9 @@ describe('profiling HostRoot', () => {
126
127
return null ;
127
128
}
128
129
129
- const container = document . createElement ( 'div' ) ;
130
- const root = ReactDOMClient . createRoot ( container ) ;
131
-
132
130
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 } /> ) ) ;
135
133
utils . act ( ( ) => store . profilerStore . stopProfiling ( ) ) ;
136
134
137
135
expect ( effectDurations ) . toHaveLength ( 3 ) ;
0 commit comments