|
10 | 10 | 'use strict';
|
11 | 11 |
|
12 | 12 | let React;
|
13 |
| -let ReactDOM; |
| 13 | +let ReactDOMClient; |
| 14 | +let act; |
14 | 15 |
|
15 | 16 | describe('Component stack trace displaying', () => {
|
16 | 17 | beforeEach(() => {
|
17 | 18 | React = require('react');
|
18 |
| - ReactDOM = require('react-dom'); |
| 19 | + ReactDOMClient = require('react-dom'); |
| 20 | + act = require('internal-test-utils').act; |
19 | 21 | });
|
20 | 22 |
|
21 | 23 | // @gate !enableComponentStackLocations || !__DEV__
|
22 |
| - it('should provide filenames in stack traces', () => { |
| 24 | + it('should provide filenames in stack traces', async () => { |
23 | 25 | class Component extends React.Component {
|
24 | 26 | render() {
|
25 | 27 | return [<span>a</span>, <span>b</span>];
|
@@ -88,15 +90,21 @@ describe('Component stack trace displaying', () => {
|
88 | 90 | 'C:\\funny long (path)/index.js': 'funny long (path)/index.js',
|
89 | 91 | 'C:\\funny long (path)/index.jsx': 'funny long (path)/index.jsx',
|
90 | 92 | };
|
91 |
| - Object.keys(fileNames).forEach((fileName, i) => { |
| 93 | + |
| 94 | + const root = ReactDOMClient.createRoot(container); |
| 95 | + |
| 96 | + let i = 0; |
| 97 | + for (const fileName in fileNames) { |
92 | 98 | Component.displayName = 'Component ' + i;
|
93 |
| - ReactDOM.render( |
94 |
| - <Component __source={{fileName, lineNumber: i}} />, |
95 |
| - container, |
96 |
| - ); |
97 |
| - }); |
| 99 | + |
| 100 | + await act(() => { |
| 101 | + root.render(<Component __source={{fileName, lineNumber: i}} />); |
| 102 | + }); |
| 103 | + |
| 104 | + i++; |
| 105 | + } |
98 | 106 | if (__DEV__) {
|
99 |
| - let i = 0; |
| 107 | + i = 0; |
100 | 108 | expect(console.error).toHaveBeenCalledTimes(
|
101 | 109 | Object.keys(fileNames).length,
|
102 | 110 | );
|
|
0 commit comments