Skip to content
Merged
Show file tree
Hide file tree
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
33 changes: 20 additions & 13 deletions packages/react-devtools-shared/src/__tests__/preprocessData-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,8 @@ let utils;
let assertLog;
let waitFor;

// This flag is on experimental which disables timeline profiler.
const enableComponentPerformanceTrack =
React.version.startsWith('19') && React.version.includes('experimental');

describe('Timeline profiler', () => {
if (enableComponentPerformanceTrack) {
test('no tests', () => {});
// Ignore all tests.
return;
}

describe('User Timing API', () => {
if (enableComponentPerformanceTrack) {
return;
}
let currentlyNotClearedMarks;
let registeredMarks;
let featureDetectionMarkName = null;
Expand Down Expand Up @@ -168,6 +155,7 @@ describe('Timeline profiler', () => {
});

// @reactVersion >= 18.0
// @reactVersion < 19.2
it('should return array of lane numbers from bitmask string', () => {
expect(getLanesFromTransportDecimalBitmask('1')).toEqual([0]);
expect(getLanesFromTransportDecimalBitmask('512')).toEqual([9]);
Expand All @@ -184,6 +172,7 @@ describe('Timeline profiler', () => {
});

// @reactVersion >= 18.0
// @reactVersion < 19.2
it('should return empty array if laneBitmaskString is not a bitmask', () => {
expect(getLanesFromTransportDecimalBitmask('')).toEqual([]);
expect(getLanesFromTransportDecimalBitmask('hello')).toEqual([]);
Expand All @@ -192,6 +181,7 @@ describe('Timeline profiler', () => {
});

// @reactVersion >= 18.0
// @reactVersion < 19.2
it('should ignore lanes outside REACT_TOTAL_NUM_LANES', () => {
const REACT_TOTAL_NUM_LANES =
require('react-devtools-timeline/src/constants').REACT_TOTAL_NUM_LANES;
Expand Down Expand Up @@ -317,11 +307,13 @@ describe('Timeline profiler', () => {
});

// @reactVersion >= 18.0
// @reactVersion < 19.2
it('should throw given an empty timeline', async () => {
await expect(async () => preprocessData([])).rejects.toThrow();
});

// @reactVersion >= 18.0
// @reactVersion < 19.2
it('should throw given a timeline with no Profile event', async () => {
const randomSample = createUserTimingEntry({
dur: 100,
Expand All @@ -338,6 +330,7 @@ describe('Timeline profiler', () => {
});

// @reactVersion >= 18.0
// @reactVersion < 19.2
it('should throw given a timeline without an explicit profiler version mark nor any other React marks', async () => {
const cpuProfilerSample = creactCpuProfilerSample();

Expand All @@ -349,6 +342,7 @@ describe('Timeline profiler', () => {
});

// @reactVersion >= 18.0
// @reactVersion < 19.2
it('should throw given a timeline with React scheduling marks, but without an explicit profiler version mark', async () => {
const cpuProfilerSample = creactCpuProfilerSample();
const scheduleRenderSample = createUserTimingEntry({
Expand All @@ -363,6 +357,7 @@ describe('Timeline profiler', () => {
});

// @reactVersion >= 18.0
// @reactVersion < 19.2
it('should return empty data given a timeline with no React scheduling profiling marks', async () => {
const cpuProfilerSample = creactCpuProfilerSample();
const randomSample = createUserTimingEntry({
Expand Down Expand Up @@ -467,6 +462,7 @@ describe('Timeline profiler', () => {
});

// @reactVersion >= 18.0
// @reactVersion < 19.2
it('should process legacy data format (before lane labels were added)', async () => {
const cpuProfilerSample = creactCpuProfilerSample();

Expand Down Expand Up @@ -854,6 +850,7 @@ describe('Timeline profiler', () => {
`);
});

// @reactVersion < 19.2
it('should process a sample createRoot render sequence', async () => {
function App() {
const [didMount, setDidMount] = React.useState(false);
Expand Down Expand Up @@ -1190,6 +1187,7 @@ describe('Timeline profiler', () => {
});

// @reactVersion >= 18.0
// @reactVersion < 19.2
it('should populate other user timing marks', async () => {
const userTimingData = createUserTimingData([]);
userTimingData.push(
Expand Down Expand Up @@ -1240,6 +1238,7 @@ describe('Timeline profiler', () => {
});

// @reactVersion >= 18.0
// @reactVersion < 19.2
it('should include a suspended resource "displayName" if one is set', async () => {
let promise = null;
let resolvedValue = null;
Expand Down Expand Up @@ -1381,6 +1380,7 @@ describe('Timeline profiler', () => {
});

// @reactVersion >= 18.2
// @reactVersion < 19.2
it('should not warn when React finishes a previously long (async) update with a short (sync) update inside of an event', async () => {
function Yield({id, value}) {
Scheduler.log(`${id}:${value}`);
Expand Down Expand Up @@ -1443,6 +1443,7 @@ describe('Timeline profiler', () => {

describe('nested updates', () => {
// @reactVersion >= 18.2
// @reactVersion < 19.2
it('should not warn about short nested (state) updates during layout effects', async () => {
function Component() {
const [didMount, setDidMount] = React.useState(false);
Expand Down Expand Up @@ -1474,6 +1475,7 @@ describe('Timeline profiler', () => {
});

// @reactVersion >= 18.2
// @reactVersion < 19.2
it('should not warn about short (forced) updates during layout effects', async () => {
class Component extends React.Component {
_didMount: boolean = false;
Expand Down Expand Up @@ -1629,6 +1631,7 @@ describe('Timeline profiler', () => {
});

// @reactVersion >= 18.2
// @reactVersion < 19.2
it('should not warn about transition updates scheduled during commit phase', async () => {
function Component() {
const [value, setValue] = React.useState(0);
Expand Down Expand Up @@ -1770,6 +1773,7 @@ describe('Timeline profiler', () => {

describe('errors thrown while rendering', () => {
// @reactVersion >= 18.0
// @reactVersion < 19.2
it('shoult parse Errors thrown during render', async () => {
jest.spyOn(console, 'error');

Expand Down Expand Up @@ -1818,6 +1822,7 @@ describe('Timeline profiler', () => {
// This also tests an edge case where a component suspends while profiling
// before the first commit is logged (so the lane-to-labels map will not yet exist).
// @reactVersion >= 18.2
// @reactVersion < 19.2
it('should warn about suspending during an update', async () => {
let promise = null;
let resolvedValue = null;
Expand Down Expand Up @@ -1884,6 +1889,7 @@ describe('Timeline profiler', () => {
});

// @reactVersion >= 18.2
// @reactVersion < 19.2
it('should not warn about suspending during an transition', async () => {
let promise = null;
let resolvedValue = null;
Expand Down Expand Up @@ -2152,6 +2158,7 @@ describe('Timeline profiler', () => {
`);
});

// @reactVersion < 19.2
it('should process a sample createRoot render sequence', async () => {
function App() {
const [didMount, setDidMount] = React.useState(false);
Expand Down
2 changes: 1 addition & 1 deletion packages/shared/ReactFeatureFlags.js
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ export const enableProfilerTimer = __PROFILE__;
// Component rendering tracks to show up in the Performance tab.
// This flag will be used for both Server Component and Client Component tracks.
// All calls should also be gated on enableProfilerTimer.
export const enableComponentPerformanceTrack = __EXPERIMENTAL__;
export const enableComponentPerformanceTrack: boolean = true;

// Adds user timing marks for e.g. state updates, suspense, and work loop stuff,
// for an experimental timeline tool.
Expand Down
5 changes: 3 additions & 2 deletions packages/shared/forks/ReactFeatureFlags.native-oss.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,9 @@ export const enableObjectFiber: boolean = false;
export const enablePostpone: boolean = false;
export const enableReactTestRendererWarning: boolean = false;
export const enableRetryLaneExpiration: boolean = false;
export const enableSchedulingProfiler: boolean = __PROFILE__;
export const enableComponentPerformanceTrack: boolean = false;
export const enableComponentPerformanceTrack: boolean = true;
export const enableSchedulingProfiler: boolean =
!enableComponentPerformanceTrack && __PROFILE__;
export const enableScopeAPI: boolean = false;
export const enableEagerAlternateStateNodeCleanup: boolean = true;
export const enableSuspenseAvoidThisFallback: boolean = false;
Expand Down
2 changes: 1 addition & 1 deletion packages/shared/forks/ReactFeatureFlags.test-renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export const enableSchedulingProfiler: boolean = false;
export const enableProfilerTimer: boolean = __PROFILE__;
export const enableProfilerCommitHooks: boolean = __PROFILE__;
export const enableProfilerNestedUpdatePhase: boolean = __PROFILE__;
export const enableComponentPerformanceTrack: boolean = false;
export const enableComponentPerformanceTrack: boolean = true;
export const enableUpdaterTracking: boolean = false;
export const enableLegacyCache: boolean = __EXPERIMENTAL__;
export const enableAsyncIterableChildren: boolean = false;
Expand Down
Loading