@samitouri / QOS-React-1 / commits / 65db1000b9

[test] Move profilingCommitTreeBuilder to versioned renderer (#35711)

Sebastian "Sebbie" Silbermann committed Feb 6, 2026 at 16:00 UTC 65db1000b944c8a07b5947c06b38eb8364dce4f2
1 file changed +14 -157
packages/react-devtools-shared/src/__tests__/profilingCommitTreeBuilder-test.js
+14 -157
@@ -9,10 +9,7 @@
9
10 import type Store from 'react-devtools-shared/src/devtools/store';
11
12 -import {
13 - getLegacyRenderImplementation,
14 - getModernRenderImplementation,
15 -} from './utils';
12 +import {getVersionedRenderImplementation} from './utils';
13
14 describe('commit tree', () => {
15 let React = require('react');
@@ -32,12 +29,10 @@ describe('commit tree', () => {
29 Scheduler = require('scheduler');
30 });
31
35 - const {render: legacyRender} = getLegacyRenderImplementation();
36 - const {render: modernRender} = getModernRenderImplementation();
32 + const {render} = getVersionedRenderImplementation();
33
34 // @reactVersion >= 16.9
39 - // @reactVersion <= 18.2
40 - it('should be able to rebuild the store tree for each commit (legacy render)', () => {
35 + it('should be able to rebuild the store tree for each commit', () => {
36 const Parent = ({count}) => {
37 Scheduler.unstable_advanceTime(10);
38 return new Array(count)
@@ -50,13 +45,13 @@ describe('commit tree', () => {
45 });
46
47 utils.act(() => store.profilerStore.startProfiling());
53 - utils.act(() => legacyRender(<Parent count={1} />));
48 + utils.act(() => render(<Parent count={1} />));
49 expect(store).toMatchInlineSnapshot(`
50 [root]
51 ▾ <Parent>
52 <Child key="0"> [Memo]
53 `);
59 - utils.act(() => legacyRender(<Parent count={3} />));
54 + utils.act(() => render(<Parent count={3} />));
55 expect(store).toMatchInlineSnapshot(`
56 [root]
57 ▾ <Parent>
@@ -64,73 +59,14 @@ describe('commit tree', () => {
59 <Child key="1"> [Memo]
60 <Child key="2"> [Memo]
61 `);
67 - utils.act(() => legacyRender(<Parent count={2} />));
62 + utils.act(() => render(<Parent count={2} />));
63 expect(store).toMatchInlineSnapshot(`
64 [root]
65 ▾ <Parent>
66 <Child key="0"> [Memo]
67 <Child key="1"> [Memo]
68 `);
74 - utils.act(() => legacyRender(<Parent count={0} />));
75 - expect(store).toMatchInlineSnapshot(`
76 - [root]
77 - <Parent>
78 - `);
79 - utils.act(() => store.profilerStore.stopProfiling());
80 -
81 - const rootID = store.roots[0];
82 - const commitTrees = [];
83 - for (let commitIndex = 0; commitIndex < 4; commitIndex++) {
84 - commitTrees.push(
85 - store.profilerStore.profilingCache.getCommitTree({
86 - commitIndex,
87 - rootID,
88 - }),
89 - );
90 - }
91 -
92 - expect(commitTrees[0].nodes.size).toBe(3); // <Root> + <Parent> + <Child>
93 - expect(commitTrees[1].nodes.size).toBe(5); // <Root> + <Parent> + <Child> x 3
94 - expect(commitTrees[2].nodes.size).toBe(4); // <Root> + <Parent> + <Child> x 2
95 - expect(commitTrees[3].nodes.size).toBe(2); // <Root> + <Parent>
96 - });
97 -
98 - // @reactVersion >= 18
99 - it('should be able to rebuild the store tree for each commit (createRoot)', () => {
100 - const Parent = ({count}) => {
101 - Scheduler.unstable_advanceTime(10);
102 - return new Array(count)
103 - .fill(true)
104 - .map((_, index) => <Child key={index} />);
105 - };
106 - const Child = React.memo(function Child() {
107 - Scheduler.unstable_advanceTime(2);
108 - return null;
109 - });
110 -
111 - utils.act(() => store.profilerStore.startProfiling());
112 - utils.act(() => modernRender(<Parent count={1} />));
113 - expect(store).toMatchInlineSnapshot(`
114 - [root]
115 - ▾ <Parent>
116 - <Child key="0"> [Memo]
117 - `);
118 - utils.act(() => modernRender(<Parent count={3} />));
119 - expect(store).toMatchInlineSnapshot(`
120 - [root]
121 - ▾ <Parent>
122 - <Child key="0"> [Memo]
123 - <Child key="1"> [Memo]
124 - <Child key="2"> [Memo]
125 - `);
126 - utils.act(() => modernRender(<Parent count={2} />));
127 - expect(store).toMatchInlineSnapshot(`
128 - [root]
129 - ▾ <Parent>
130 - <Child key="0"> [Memo]
131 - <Child key="1"> [Memo]
132 - `);
133 - utils.act(() => modernRender(<Parent count={0} />));
69 + utils.act(() => render(<Parent count={0} />));
70 expect(store).toMatchInlineSnapshot(`
71 [root]
72 <Parent>
@@ -179,10 +115,9 @@ describe('commit tree', () => {
115 });
116
117 // @reactVersion >= 16.9
182 - // @reactVersion <= 18.2
183 - it('should support Lazy components (legacy render)', async () => {
118 + it('should support Lazy components', async () => {
119 utils.act(() => store.profilerStore.startProfiling());
185 - utils.act(() => legacyRender(<App renderChildren={true} />));
120 + utils.act(() => render(<App renderChildren={true} />));
121 await Promise.resolve();
122 expect(store).toMatchInlineSnapshot(`
123 [root]
@@ -191,7 +126,7 @@ describe('commit tree', () => {
126 [suspense-root] rects={null}
127 <Suspense name="App" rects={null}>
128 `);
194 - utils.act(() => legacyRender(<App renderChildren={true} />));
129 + utils.act(() => render(<App renderChildren={true} />));
130 expect(store).toMatchInlineSnapshot(`
131 [root]
132 ▾ <App>
@@ -200,7 +135,7 @@ describe('commit tree', () => {
135 [suspense-root] rects={null}
136 <Suspense name="App" rects={null}>
137 `);
203 - utils.act(() => legacyRender(<App renderChildren={false} />));
138 + utils.act(() => render(<App renderChildren={false} />));
139 expect(store).toMatchInlineSnapshot(`
140 [root]
141 <App>
@@ -223,55 +158,10 @@ describe('commit tree', () => {
158 expect(commitTrees[2].nodes.size).toBe(2); // <Root> + <App>
159 });
160
226 - // @reactVersion >= 18.0
227 - it('should support Lazy components (createRoot)', async () => {
228 - utils.act(() => store.profilerStore.startProfiling());
229 - utils.act(() => modernRender(<App renderChildren={true} />));
230 - await Promise.resolve();
231 - expect(store).toMatchInlineSnapshot(`
232 - [root]
233 - ▾ <App>
234 - <Suspense>
235 - [suspense-root] rects={null}
236 - <Suspense name="App" rects={null}>
237 - `);
238 - utils.act(() => modernRender(<App renderChildren={true} />));
239 - expect(store).toMatchInlineSnapshot(`
240 - [root]
241 - ▾ <App>
242 - ▾ <Suspense>
243 - <LazyInnerComponent>
244 - [suspense-root] rects={null}
245 - <Suspense name="App" rects={null}>
246 - `);
247 - utils.act(() => modernRender(<App renderChildren={false} />));
248 - expect(store).toMatchInlineSnapshot(`
249 - [root]
250 - <App>
251 - `);
252 - utils.act(() => store.profilerStore.stopProfiling());
253 -
254 - const rootID = store.roots[0];
255 - const commitTrees = [];
256 - for (let commitIndex = 0; commitIndex < 3; commitIndex++) {
257 - commitTrees.push(
258 - store.profilerStore.profilingCache.getCommitTree({
259 - commitIndex,
260 - rootID,
261 - }),
262 - );
263 - }
264 -
265 - expect(commitTrees[0].nodes.size).toBe(3); // <Root> + <App> + <Suspense>
266 - expect(commitTrees[1].nodes.size).toBe(4); // <Root> + <App> + <Suspense> + <LazyInnerComponent>
267 - expect(commitTrees[2].nodes.size).toBe(2); // <Root> + <App>
268 - });
269 -
161 // @reactVersion >= 16.9
271 - // @reactVersion <= 18.2
272 - it('should support Lazy components that are unmounted before resolving (legacy render)', async () => {
162 + it('should support Lazy components that are unmounted before resolving', async () => {
163 utils.act(() => store.profilerStore.startProfiling());
274 - utils.act(() => legacyRender(<App renderChildren={true} />));
164 + utils.act(() => render(<App renderChildren={true} />));
165 expect(store).toMatchInlineSnapshot(`
166 [root]
167 ▾ <App>
@@ -279,7 +169,7 @@ describe('commit tree', () => {
169 [suspense-root] rects={null}
170 <Suspense name="App" rects={null}>
171 `);
282 - utils.act(() => legacyRender(<App renderChildren={false} />));
172 + utils.act(() => render(<App renderChildren={false} />));
173 expect(store).toMatchInlineSnapshot(`
174 [root]
175 <App>
@@ -300,38 +190,5 @@ describe('commit tree', () => {
190 expect(commitTrees[0].nodes.size).toBe(3);
191 expect(commitTrees[1].nodes.size).toBe(2); // <Root> + <App>
192 });
303 -
304 - // @reactVersion >= 18.0
305 - it('should support Lazy components that are unmounted before resolving (createRoot)', async () => {
306 - utils.act(() => store.profilerStore.startProfiling());
307 - utils.act(() => modernRender(<App renderChildren={true} />));
308 - expect(store).toMatchInlineSnapshot(`
309 - [root]
310 - ▾ <App>
311 - <Suspense>
312 - [suspense-root] rects={null}
313 - <Suspense name="App" rects={null}>
314 - `);
315 - utils.act(() => modernRender(<App renderChildren={false} />));
316 - expect(store).toMatchInlineSnapshot(`
317 - [root]
318 - <App>
319 - `);
320 - utils.act(() => store.profilerStore.stopProfiling());
321 -
322 - const rootID = store.roots[0];
323 - const commitTrees = [];
324 - for (let commitIndex = 0; commitIndex < 2; commitIndex++) {
325 - commitTrees.push(
326 - store.profilerStore.profilingCache.getCommitTree({
327 - commitIndex,
328 - rootID,
329 - }),
330 - );
331 - }
332 -
333 - expect(commitTrees[0].nodes.size).toBe(3); // <Root> + <App> + <Suspense>
334 - expect(commitTrees[1].nodes.size).toBe(2); // <Root> + <App>
335 - });
193 });
194 });