fix[react-devtools]: fixed timeline profiler tests (#31261)

Fixes tests against React 18 after
https://github.com/facebook/react/pull/31154:
- Set `supportsTimeline` to true for `Store`.
- Execute `store.profilerStore.startProfiling` after `legacyRender`
import, because this is where `react-dom` is imported and renderer is
registered. We don't yet propagate `isProfiling` flag to newly
registered renderers, when profiling already started see:

https://github.com/facebook/react/blob/d5bba18b5d81f234657586865248c5b6849599cd/packages/react-devtools-shared/src/hook.js#L203-L204
This commit is contained in:
Ruslan Lesiutin
2024-10-15 12:46:05 +01:00
committed by GitHub
parent 13411e4589
commit ec2bf02245
2 changed files with 11 additions and 5 deletions
@@ -1280,13 +1280,13 @@ describe('Timeline profiler', () => {
});
describe('when profiling', () => {
beforeEach(() => {
utils.act(() => store.profilerStore.startProfiling());
});
describe('with legacy render', () => {
const {render: legacyRender} = getLegacyRenderImplementation();
beforeEach(() => {
utils.act(() => store.profilerStore.startProfiling());
});
// @reactVersion <= 18.2
// @reactVersion >= 18.0
it('should mark sync render without suspends or state updates', () => {
@@ -1537,6 +1537,10 @@ describe('Timeline profiler', () => {
const {render: modernRender} = getModernRenderImplementation();
beforeEach(() => {
utils.act(() => store.profilerStore.startProfiling());
});
it('should mark concurrent render without suspends or state updates', () => {
utils.act(() => modernRender(<div />));
+3 -1
View File
@@ -256,7 +256,9 @@ beforeEach(() => {
},
});
const store = new Store(((bridge: any): FrontendBridge));
const store = new Store(((bridge: any): FrontendBridge), {
supportsTimeline: true,
});
const agent = new Agent(((bridge: any): BackendBridge));
const hook = global.__REACT_DEVTOOLS_GLOBAL_HOOK__;