Skip to content

Commit 63a9dd4

Browse files
committed
add react version to tests
1 parent 357a613 commit 63a9dd4

21 files changed

+248
-0
lines changed

packages/react-devtools-shared/src/__tests__/FastRefreshDevToolsIntegration-test.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ describe('Fast Refresh', () => {
123123
return ReactFreshRuntime.createSignatureFunctionForTransform();
124124
}
125125

126+
// @reactVersion >= 16.9
126127
it('should not break the DevTools store', () => {
127128
render(`
128129
function Parent() {
@@ -186,6 +187,7 @@ describe('Fast Refresh', () => {
186187
expect(container.firstChild).not.toBe(element);
187188
});
188189

190+
// @reactVersion >= 16.9
189191
it('should not break when there are warnings in between patching', () => {
190192
withErrorsOrWarningsIgnored(['Expected:'], () => {
191193
render(`

packages/react-devtools-shared/src/__tests__/TimelineProfiler-test.js

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ describe('Timeline profiler', () => {
124124
setPerformanceMock(null);
125125
});
126126

127+
// @reactVersion >=18.0
127128
it('should mark sync render without suspends or state updates', () => {
128129
renderHelper(<div />);
129130

@@ -145,6 +146,7 @@ describe('Timeline profiler', () => {
145146
`);
146147
});
147148

149+
// @reactVersion >=18.0
148150
it('should mark concurrent render without suspends or state updates', () => {
149151
renderRootHelper(<div />);
150152

@@ -175,6 +177,7 @@ describe('Timeline profiler', () => {
175177
`);
176178
});
177179

180+
// @reactVersion >=18.0
178181
it('should mark render yields', async () => {
179182
function Bar() {
180183
Scheduler.unstable_yieldValue('Bar');
@@ -204,6 +207,7 @@ describe('Timeline profiler', () => {
204207
`);
205208
});
206209

210+
// @reactVersion >=18.0
207211
it('should mark sync render with suspense that resolves', async () => {
208212
const fakeSuspensePromise = Promise.resolve(true);
209213
function Example() {
@@ -246,6 +250,7 @@ describe('Timeline profiler', () => {
246250
`);
247251
});
248252

253+
// @reactVersion >=18.0
249254
it('should mark sync render with suspense that rejects', async () => {
250255
const fakeSuspensePromise = Promise.reject(new Error('error'));
251256
function Example() {
@@ -284,6 +289,7 @@ describe('Timeline profiler', () => {
284289
expect(clearedMarks).toContain(`--suspense-rejected-0-Example`);
285290
});
286291

292+
// @reactVersion >=18.0
287293
it('should mark concurrent render with suspense that resolves', async () => {
288294
const fakeSuspensePromise = Promise.resolve(true);
289295
function Example() {
@@ -335,6 +341,7 @@ describe('Timeline profiler', () => {
335341
`);
336342
});
337343

344+
// @reactVersion >=18.0
338345
it('should mark concurrent render with suspense that rejects', async () => {
339346
const fakeSuspensePromise = Promise.reject(new Error('error'));
340347
function Example() {
@@ -386,6 +393,7 @@ describe('Timeline profiler', () => {
386393
`);
387394
});
388395

396+
// @reactVersion >=18.0
389397
it('should mark cascading class component state updates', () => {
390398
class Example extends React.Component {
391399
state = {didMount: false};
@@ -440,6 +448,7 @@ describe('Timeline profiler', () => {
440448
`);
441449
});
442450

451+
// @reactVersion >=18.0
443452
it('should mark cascading class component force updates', () => {
444453
class Example extends React.Component {
445454
componentDidMount() {
@@ -493,6 +502,7 @@ describe('Timeline profiler', () => {
493502
`);
494503
});
495504

505+
// @reactVersion >=18.0
496506
it('should mark render phase state updates for class component', () => {
497507
class Example extends React.Component {
498508
state = {didRender: false};
@@ -546,6 +556,7 @@ describe('Timeline profiler', () => {
546556
`);
547557
});
548558

559+
// @reactVersion >=18.0
549560
it('should mark render phase force updates for class component', () => {
550561
let forced = false;
551562
class Example extends React.Component {
@@ -600,6 +611,7 @@ describe('Timeline profiler', () => {
600611
`);
601612
});
602613

614+
// @reactVersion >=18.0
603615
it('should mark cascading layout updates', () => {
604616
function Example() {
605617
const [didMount, setDidMount] = React.useState(false);
@@ -654,6 +666,7 @@ describe('Timeline profiler', () => {
654666
`);
655667
});
656668

669+
// @reactVersion >=18.0
657670
it('should mark cascading passive updates', () => {
658671
function Example() {
659672
const [didMount, setDidMount] = React.useState(false);
@@ -703,6 +716,7 @@ describe('Timeline profiler', () => {
703716
`);
704717
});
705718

719+
// @reactVersion >=18.0
706720
it('should mark render phase updates', () => {
707721
function Example() {
708722
const [didRender, setDidRender] = React.useState(false);
@@ -737,6 +751,7 @@ describe('Timeline profiler', () => {
737751
`);
738752
});
739753

754+
// @reactVersion >=18.0
740755
it('should mark sync render that throws', async () => {
741756
spyOn(console, 'error');
742757

@@ -799,6 +814,7 @@ describe('Timeline profiler', () => {
799814
`);
800815
});
801816

817+
// @reactVersion >=18.0
802818
it('should mark concurrent render that throws', async () => {
803819
spyOn(console, 'error');
804820

@@ -879,6 +895,7 @@ describe('Timeline profiler', () => {
879895
`);
880896
});
881897

898+
// @reactVersion >=18.0
882899
it('should mark passive and layout effects', async () => {
883900
function ComponentWithEffects() {
884901
React.useLayoutEffect(() => {
@@ -1015,6 +1032,7 @@ describe('Timeline profiler', () => {
10151032
});
10161033

10171034
describe('lane labels', () => {
1035+
// @reactVersion >=18.0
10181036
it('regression test SyncLane', () => {
10191037
renderHelper(<div />);
10201038

@@ -1036,6 +1054,7 @@ describe('Timeline profiler', () => {
10361054
`);
10371055
});
10381056

1057+
// @reactVersion >=18.0
10391058
it('regression test DefaultLane', () => {
10401059
renderRootHelper(<div />);
10411060
expect(clearedMarks).toMatchInlineSnapshot(`
@@ -1045,6 +1064,7 @@ describe('Timeline profiler', () => {
10451064
`);
10461065
});
10471066

1067+
// @reactVersion >=18.0
10481068
it('regression test InputDiscreteLane', async () => {
10491069
const targetRef = React.createRef(null);
10501070

@@ -1086,6 +1106,7 @@ describe('Timeline profiler', () => {
10861106
`);
10871107
});
10881108

1109+
// @reactVersion >=18.0
10891110
it('regression test InputContinuousLane', async () => {
10901111
const targetRef = React.createRef(null);
10911112

@@ -1170,6 +1191,7 @@ describe('Timeline profiler', () => {
11701191
utils.act(() => store.profilerStore.startProfiling());
11711192
});
11721193

1194+
// @reactVersion >=18.0
11731195
it('should mark sync render without suspends or state updates', () => {
11741196
renderHelper(<div />);
11751197

@@ -1186,6 +1208,7 @@ describe('Timeline profiler', () => {
11861208
`);
11871209
});
11881210

1211+
// @reactVersion >=18.0
11891212
it('should mark concurrent render without suspends or state updates', () => {
11901213
utils.act(() => renderRootHelper(<div />));
11911214

@@ -1202,6 +1225,7 @@ describe('Timeline profiler', () => {
12021225
`);
12031226
});
12041227

1228+
// @reactVersion >=18.0
12051229
it('should mark concurrent render without suspends or state updates', () => {
12061230
let updaterFn;
12071231

@@ -1281,6 +1305,7 @@ describe('Timeline profiler', () => {
12811305
expect(timelineData.batchUIDToMeasuresMap.size).toBe(2);
12821306
});
12831307

1308+
// @reactVersion >=18.0
12841309
it('should mark render yields', async () => {
12851310
function Bar() {
12861311
Scheduler.unstable_yieldValue('Bar');
@@ -1365,6 +1390,7 @@ describe('Timeline profiler', () => {
13651390
expect(timelineData.componentMeasures).toHaveLength(2);
13661391
});
13671392

1393+
// @reactVersion >=18.0
13681394
it('should mark sync render with suspense that rejects', async () => {
13691395
let rejectFn;
13701396
let rejected = false;
@@ -1422,6 +1448,7 @@ describe('Timeline profiler', () => {
14221448
expect(timelineData.componentMeasures).toHaveLength(2);
14231449
});
14241450

1451+
// @reactVersion >=18.0
14251452
it('should mark concurrent render with suspense that resolves', async () => {
14261453
let resolveFn;
14271454
let resolved = false;
@@ -1479,6 +1506,7 @@ describe('Timeline profiler', () => {
14791506
expect(timelineData.componentMeasures).toHaveLength(2);
14801507
});
14811508

1509+
// @reactVersion >=18.0
14821510
it('should mark concurrent render with suspense that rejects', async () => {
14831511
let rejectFn;
14841512
let rejected = false;
@@ -1536,6 +1564,7 @@ describe('Timeline profiler', () => {
15361564
expect(timelineData.componentMeasures).toHaveLength(2);
15371565
});
15381566

1567+
// @reactVersion >=18.0
15391568
it('should mark cascading class component state updates', () => {
15401569
class Example extends React.Component {
15411570
state = {didMount: false};
@@ -1594,6 +1623,7 @@ describe('Timeline profiler', () => {
15941623
`);
15951624
});
15961625

1626+
// @reactVersion >=18.0
15971627
it('should mark cascading class component force updates', () => {
15981628
let forced = false;
15991629
class Example extends React.Component {
@@ -1651,6 +1681,7 @@ describe('Timeline profiler', () => {
16511681
`);
16521682
});
16531683

1684+
// @reactVersion >=18.0
16541685
it('should mark render phase state updates for class component', () => {
16551686
class Example extends React.Component {
16561687
state = {didRender: false};
@@ -1719,6 +1750,7 @@ describe('Timeline profiler', () => {
17191750
`);
17201751
});
17211752

1753+
// @reactVersion >=18.0
17221754
it('should mark render phase force updates for class component', () => {
17231755
let forced = false;
17241756
class Example extends React.Component {
@@ -1786,6 +1818,7 @@ describe('Timeline profiler', () => {
17861818
`);
17871819
});
17881820

1821+
// @reactVersion >=18.0
17891822
it('should mark cascading layout updates', () => {
17901823
function Example() {
17911824
const [didMount, setDidMount] = React.useState(false);
@@ -1848,6 +1881,7 @@ describe('Timeline profiler', () => {
18481881
`);
18491882
});
18501883

1884+
// @reactVersion >=18.0
18511885
it('should mark cascading passive updates', () => {
18521886
function Example() {
18531887
const [didMount, setDidMount] = React.useState(false);
@@ -1909,6 +1943,7 @@ describe('Timeline profiler', () => {
19091943
`);
19101944
});
19111945

1946+
// @reactVersion >=18.0
19121947
it('should mark render phase updates', () => {
19131948
function Example() {
19141949
const [didRender, setDidRender] = React.useState(false);
@@ -1956,6 +1991,7 @@ describe('Timeline profiler', () => {
19561991
`);
19571992
});
19581993

1994+
// @reactVersion >=18.0
19591995
it('should mark sync render that throws', async () => {
19601996
spyOn(console, 'error');
19611997

@@ -2049,6 +2085,7 @@ describe('Timeline profiler', () => {
20492085
`);
20502086
});
20512087

2088+
// @reactVersion >=18.0
20522089
it('should mark concurrent render that throws', async () => {
20532090
spyOn(console, 'error');
20542091

@@ -2167,6 +2204,7 @@ describe('Timeline profiler', () => {
21672204
`);
21682205
});
21692206

2207+
// @reactVersion >=18.0
21702208
it('should mark passive and layout effects', async () => {
21712209
function ComponentWithEffects() {
21722210
React.useLayoutEffect(() => {
@@ -2406,6 +2444,7 @@ describe('Timeline profiler', () => {
24062444
});
24072445

24082446
describe('when not profiling', () => {
2447+
// @reactVersion >=18.0
24092448
it('should not log any marks', () => {
24102449
renderHelper(<div />);
24112450

packages/react-devtools-shared/src/__tests__/bridge-test.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ describe('Bridge', () => {
1414
Bridge = require('react-devtools-shared/src/bridge').default;
1515
});
1616

17+
// @reactVersion >=16.0
1718
it('should shutdown properly', () => {
1819
const wall = {
1920
listen: jest.fn(() => () => {}),

packages/react-devtools-shared/src/__tests__/componentStacks-test.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ describe('component stack', () => {
4949
React = require('react');
5050
});
5151

52+
// @reactVersion >=16.9
5253
it('should log the current component stack along with an error or warning', () => {
5354
const Grandparent = () => <Parent />;
5455
const Parent = () => <Child />;

0 commit comments

Comments
 (0)