@samitouri / QOS-React-1 / commits / 6fef0cb568

chore: use versioned render in profilingHostRoot test and gate some for legacy rendering (#28237)

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