Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,14 @@
* @flow
*/

import {
getLegacyRenderImplementation,
getModernRenderImplementation,
} from './utils';

describe('profiling HostRoot', () => {
let React;
let ReactDOMClient;
let Scheduler;
let legacyRender;
let store;
let utils;
let getEffectDurations;
Expand All @@ -22,14 +25,11 @@ describe('profiling HostRoot', () => {
utils = require('./utils');
utils.beforeEachProfiling();

legacyRender = utils.legacyRender;

getEffectDurations = require('../backend/utils').getEffectDurations;

store = global.store;

React = require('react');
ReactDOMClient = require('react-dom/client');
Scheduler = require('scheduler');

effectDurations = [];
Expand All @@ -49,7 +49,11 @@ describe('profiling HostRoot', () => {
};
});

// @reactVersion >=18.0
const {render: legacyRender} = getLegacyRenderImplementation();
const {render: modernRender} = getModernRenderImplementation();

// @reactVersion >= 18.0
// @reactVersion <= 18.2
it('should expose passive and layout effect durations for render()', () => {
function App() {
React.useEffect(() => {
Expand All @@ -63,8 +67,7 @@ describe('profiling HostRoot', () => {

utils.act(() => store.profilerStore.startProfiling());
utils.act(() => {
const container = document.createElement('div');
legacyRender(<App />, container);
legacyRender(<App />);
});
utils.act(() => store.profilerStore.stopProfiling());

Expand Down Expand Up @@ -92,9 +95,7 @@ describe('profiling HostRoot', () => {

utils.act(() => store.profilerStore.startProfiling());
utils.act(() => {
const container = document.createElement('div');
const root = ReactDOMClient.createRoot(container);
root.render(<App />);
modernRender(<App />);
});
utils.act(() => store.profilerStore.stopProfiling());

Expand Down Expand Up @@ -126,12 +127,9 @@ describe('profiling HostRoot', () => {
return null;
}

const container = document.createElement('div');
const root = ReactDOMClient.createRoot(container);

utils.act(() => store.profilerStore.startProfiling());
utils.act(() => root.render(<App />));
utils.act(() => root.render(<App shouldCascade={true} />));
utils.act(() => modernRender(<App />));
utils.act(() => modernRender(<App shouldCascade={true} />));
utils.act(() => store.profilerStore.stopProfiling());

expect(effectDurations).toHaveLength(3);
Expand Down