From f8788781405e810c7834f6697e817096755e50a8 Mon Sep 17 00:00:00 2001 From: Sebastian Silbermann Date: Fri, 2 Feb 2024 09:15:53 +0100 Subject: [PATCH] Convert multiple-copies-of-react to createRoot (#28198) --- .../__tests__/multiple-copies-of-react-test.js | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) 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' +