Skip to content
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

Remove remaining usages of ReactTestUtils in tests unrelated to react-dom/test-util #28534

Merged
merged 1 commit into from
Mar 11, 2024
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 @@ -1237,12 +1237,14 @@ describe('ProfilingCache', () => {
);
}

const {Simulate} = require('react-dom/test-utils');

utils.act(() => render(<App />));
expect(getContainer().textContent).toBe('Home');
utils.act(() => store.profilerStore.startProfiling());
utils.act(() => Simulate.click(linkRef.current));
utils.act(() =>
linkRef.current.dispatchEvent(
new MouseEvent('click', {bubbles: true, cancelable: true}),
),
);
utils.act(() => store.profilerStore.stopProfiling());
expect(getContainer().textContent).toBe('About');
});
Expand Down
7 changes: 4 additions & 3 deletions packages/react-dom/src/__tests__/ReactLegacyMount-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ const {COMMENT_NODE} = require('react-dom-bindings/src/client/HTMLNodeType');
let React;
let ReactDOM;
let ReactDOMServer;
let ReactTestUtils;
let Scheduler;
let ReactDOMClient;
let assertLog;
Expand All @@ -28,7 +27,6 @@ describe('ReactMount', () => {
ReactDOM = require('react-dom');
ReactDOMClient = require('react-dom/client');
ReactDOMServer = require('react-dom/server');
ReactTestUtils = require('react-dom/test-utils');
Scheduler = require('scheduler');

const InternalTestUtils = require('internal-test-utils');
Expand Down Expand Up @@ -71,7 +69,10 @@ describe('ReactMount', () => {
}
}

expect(() => ReactTestUtils.renderIntoDocument(Component)).toErrorDev(
expect(() => {
const container = document.createElement('div');
ReactDOM.render(Component, container);
}).toErrorDev(
'Functions are not valid as a React child. ' +
'This may happen if you return Component instead of <Component /> from render. ' +
'Or maybe you meant to call this function rather than return it.\n' +
Expand Down
18 changes: 13 additions & 5 deletions packages/react-dom/src/__tests__/findDOMNode-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

const React = require('react');
const ReactDOM = require('react-dom');
const ReactTestUtils = require('react-dom/test-utils');
const StrictMode = React.StrictMode;

describe('findDOMNode', () => {
Expand All @@ -31,7 +30,8 @@ describe('findDOMNode', () => {
}
}

const myNode = ReactTestUtils.renderIntoDocument(<MyNode />);
const container = document.createElement('div');
const myNode = ReactDOM.render(<MyNode />, container);
const myDiv = ReactDOM.findDOMNode(myNode);
const mySameDiv = ReactDOM.findDOMNode(myDiv);
expect(myDiv.tagName).toBe('DIV');
Expand Down Expand Up @@ -99,7 +99,10 @@ describe('findDOMNode', () => {
return <div />;
}
}
expect(() => ReactTestUtils.renderIntoDocument(<Bar />)).not.toThrow();
expect(() => {
const container = document.createElement('div');
ReactDOM.render(<Bar />, container);
}).not.toThrow();
});

// @gate !disableLegacyMode
Expand All @@ -117,8 +120,10 @@ describe('findDOMNode', () => {
}
}

ReactTestUtils.renderIntoDocument(
const container = document.createElement('div');
ReactDOM.render(
<ContainsStrictModeChild ref={n => (parent = n)} />,
container,
);

let match;
Expand All @@ -145,10 +150,13 @@ describe('findDOMNode', () => {
}
}

ReactTestUtils.renderIntoDocument(
const container = document.createElement('div');

ReactDOM.render(
<StrictMode>
<IsInStrictMode ref={n => (parent = n)} />
</StrictMode>,
container,
);

let match;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ const React = require('react');
const PropTypes = require('prop-types');
const ReactDOM = require('react-dom');
const ReactDOMClient = require('react-dom/client');
const ReactTestUtils = require('react-dom/test-utils');
const act = require('internal-test-utils').act;
const renderSubtreeIntoContainer =
require('react-dom').unstable_renderSubtreeIntoContainer;
Expand Down Expand Up @@ -60,7 +59,8 @@ describe('renderSubtreeIntoContainer', () => {
}
}

ReactTestUtils.renderIntoDocument(<Parent />);
const container = document.createElement('div');
ReactDOM.render(<Parent />, container);
expect(portal.firstChild.innerHTML).toBe('bar');
});

Expand Down
1 change: 0 additions & 1 deletion packages/react/src/__tests__/ReactTypeScriptClass-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import React = require('react');
import ReactDOM = require('react-dom');
import ReactDOMClient = require('react-dom/client');
import ReactDOMTestUtils = require('react-dom/test-utils');
import PropTypes = require('prop-types');
import ReactFeatureFlags = require('shared/ReactFeatureFlags');

Expand Down