diff --git a/packages/react-dom/src/__tests__/multiple-copies-of-react-test.js b/packages/react-dom/src/__tests__/multiple-copies-of-react-test.js
index 1de130b2fed2d..96647eed81cf4 100644
--- a/packages/react-dom/src/__tests__/multiple-copies-of-react-test.js
+++ b/packages/react-dom/src/__tests__/multiple-copies-of-react-test.js
@@ -10,7 +10,8 @@
'use strict';
let React = require('react');
-const ReactTestUtils = require('react-dom/test-utils');
+const ReactDOMClient = require('react-dom/client');
+const act = require('internal-test-utils').act;
class TextWithStringRef extends React.Component {
render() {
@@ -21,10 +22,14 @@ class TextWithStringRef extends React.Component {
}
describe('when different React version is used with string ref', () => {
- it('throws the "Refs must have owner" warning', () => {
- expect(() => {
- ReactTestUtils.renderIntoDocument();
- }).toThrow(
+ it('throws the "Refs must have owner" warning', async () => {
+ const container = document.createElement('div');
+ const root = ReactDOMClient.createRoot(container);
+ await expect(
+ act(() => {
+ root.render();
+ }),
+ ).rejects.toThrow(
'Element ref was specified as a string (foo) but no owner was set. This could happen for one of' +
' the following reasons:\n' +
'1. You may be adding a ref to a function component\n' +