diff --git a/packages/shared/__tests__/describeComponentFrame-test.js b/packages/shared/__tests__/describeComponentFrame-test.js
index 6a8166893fe70..37eaafb5ed279 100644
--- a/packages/shared/__tests__/describeComponentFrame-test.js
+++ b/packages/shared/__tests__/describeComponentFrame-test.js
@@ -10,16 +10,18 @@
'use strict';
let React;
-let ReactDOM;
+let ReactDOMClient;
+let act;
describe('Component stack trace displaying', () => {
beforeEach(() => {
React = require('react');
- ReactDOM = require('react-dom');
+ ReactDOMClient = require('react-dom');
+ act = require('internal-test-utils').act;
});
// @gate !enableComponentStackLocations || !__DEV__
- it('should provide filenames in stack traces', () => {
+ it('should provide filenames in stack traces', async () => {
class Component extends React.Component {
render() {
return [a, b];
@@ -88,15 +90,21 @@ describe('Component stack trace displaying', () => {
'C:\\funny long (path)/index.js': 'funny long (path)/index.js',
'C:\\funny long (path)/index.jsx': 'funny long (path)/index.jsx',
};
- Object.keys(fileNames).forEach((fileName, i) => {
+
+ const root = ReactDOMClient.createRoot(container);
+
+ let i = 0;
+ for (const fileName in fileNames) {
Component.displayName = 'Component ' + i;
- ReactDOM.render(
- ,
- container,
- );
- });
+
+ await act(() => {
+ root.render();
+ });
+
+ i++;
+ }
if (__DEV__) {
- let i = 0;
+ i = 0;
expect(console.error).toHaveBeenCalledTimes(
Object.keys(fileNames).length,
);