Skip to content

[DevTools] Add React Version Pragma to Tests #24576

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 18, 2022
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
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ describe('Fast Refresh', () => {
return ReactFreshRuntime.createSignatureFunctionForTransform();
}

// @reactVersion >= 16.9
it('should not break the DevTools store', () => {
render(`
function Parent() {
Expand Down Expand Up @@ -186,6 +187,7 @@ describe('Fast Refresh', () => {
expect(container.firstChild).not.toBe(element);
});

// @reactVersion >= 16.9
it('should not break when there are warnings in between patching', () => {
withErrorsOrWarningsIgnored(['Expected:'], () => {
render(`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ describe('Timeline profiler', () => {
setPerformanceMock(null);
});

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

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

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

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

// @reactVersion >=18.0
it('should mark render yields', async () => {
function Bar() {
Scheduler.unstable_yieldValue('Bar');
Expand Down Expand Up @@ -204,6 +207,7 @@ describe('Timeline profiler', () => {
`);
});

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

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

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

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

// @reactVersion >=18.0
it('should mark cascading class component state updates', () => {
class Example extends React.Component {
state = {didMount: false};
Expand Down Expand Up @@ -440,6 +448,7 @@ describe('Timeline profiler', () => {
`);
});

// @reactVersion >=18.0
it('should mark cascading class component force updates', () => {
class Example extends React.Component {
componentDidMount() {
Expand Down Expand Up @@ -493,6 +502,7 @@ describe('Timeline profiler', () => {
`);
});

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

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

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

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

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

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

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

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

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

// @reactVersion >=18.0
it('should mark passive and layout effects', async () => {
function ComponentWithEffects() {
React.useLayoutEffect(() => {
Expand Down Expand Up @@ -1015,6 +1032,7 @@ describe('Timeline profiler', () => {
});

describe('lane labels', () => {
// @reactVersion >=18.0
it('regression test SyncLane', () => {
renderHelper(<div />);

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

// @reactVersion >=18.0
it('regression test DefaultLane', () => {
renderRootHelper(<div />);
expect(clearedMarks).toMatchInlineSnapshot(`
Expand All @@ -1045,6 +1064,7 @@ describe('Timeline profiler', () => {
`);
});

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

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

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

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

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

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

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

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

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

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

// @reactVersion >=18.0
it('should mark render yields', async () => {
function Bar() {
Scheduler.unstable_yieldValue('Bar');
Expand Down Expand Up @@ -1365,6 +1390,7 @@ describe('Timeline profiler', () => {
expect(timelineData.componentMeasures).toHaveLength(2);
});

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

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

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

// @reactVersion >=18.0
it('should mark cascading class component state updates', () => {
class Example extends React.Component {
state = {didMount: false};
Expand Down Expand Up @@ -1594,6 +1623,7 @@ describe('Timeline profiler', () => {
`);
});

// @reactVersion >=18.0
it('should mark cascading class component force updates', () => {
let forced = false;
class Example extends React.Component {
Expand Down Expand Up @@ -1651,6 +1681,7 @@ describe('Timeline profiler', () => {
`);
});

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

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

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

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

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

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

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

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

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

// @reactVersion >=18.0
it('should mark passive and layout effects', async () => {
function ComponentWithEffects() {
React.useLayoutEffect(() => {
Expand Down Expand Up @@ -2406,6 +2444,7 @@ describe('Timeline profiler', () => {
});

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ describe('Bridge', () => {
Bridge = require('react-devtools-shared/src/bridge').default;
});

// @reactVersion >=16.0
it('should shutdown properly', () => {
const wall = {
listen: jest.fn(() => () => {}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ describe('component stack', () => {
React = require('react');
});

// @reactVersion >=16.9
it('should log the current component stack along with an error or warning', () => {
const Grandparent = () => <Parent />;
const Parent = () => <Child />;
Expand Down
Loading