Skip to content

Commit

Permalink
Convert describeComponentFrame to createRoot (#28001)
Browse files Browse the repository at this point in the history
  • Loading branch information
eps1lon authored Jan 22, 2024
1 parent 206934f commit e1d20fc
Showing 1 changed file with 18 additions and 10 deletions.
28 changes: 18 additions & 10 deletions packages/shared/__tests__/describeComponentFrame-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 [<span>a</span>, <span>b</span>];
Expand Down Expand Up @@ -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(
<Component __source={{fileName, lineNumber: i}} />,
container,
);
});

await act(() => {
root.render(<Component __source={{fileName, lineNumber: i}} />);
});

i++;
}
if (__DEV__) {
let i = 0;
i = 0;
expect(console.error).toHaveBeenCalledTimes(
Object.keys(fileNames).length,
);
Expand Down

0 comments on commit e1d20fc

Please sign in to comment.