Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions packages/react/src/__tests__/ReactJSXElementValidator-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@
// of dynamic errors when using JSX with Flow.
let React;
let ReactDOM;
let ReactDOMClient;
let ReactTestUtils;
let PropTypes;
let act;

describe('ReactJSXElementValidator', () => {
let Component;
Expand All @@ -26,7 +28,9 @@ describe('ReactJSXElementValidator', () => {
PropTypes = require('prop-types');
React = require('react');
ReactDOM = require('react-dom');
ReactDOMClient = require('react-dom/client');
ReactTestUtils = require('react-dom/test-utils');
act = require('internal-test-utils').act;

Component = class extends React.Component {
render() {
Expand Down Expand Up @@ -172,7 +176,7 @@ describe('ReactJSXElementValidator', () => {
);
});

it('should update component stack after receiving next element', () => {
it('should update component stack after receiving next element', async () => {
function MyComp() {
return null;
}
Expand All @@ -192,9 +196,14 @@ describe('ReactJSXElementValidator', () => {
}

const container = document.createElement('div');
ReactDOM.render(<ParentComp warn={false} />, container);
const root = ReactDOMClient.createRoot(container);
await act(() => {
root.render(<ParentComp warn={false} />);
});
expect(() =>
ReactDOM.render(<ParentComp warn={true} />, container),
ReactDOM.flushSync(() => {
root.render(<ParentComp warn={true} />);
}),
).toErrorDev(
'Warning: Failed prop type: ' +
'Invalid prop `color` of type `number` supplied to `MyComp`, ' +
Expand Down