(instance = current)} />);
+ });
+
+ ReactTestUtils.Simulate.click(instance.childRef.current, {
clientX: CLIENT_X,
});
});
- it('should set the type of the event', () => {
+ it('should set the type of the event', async () => {
let event;
const stub = jest.fn().mockImplementation(e => {
e.persist();
@@ -413,8 +476,11 @@ describe('ReactTestUtils', () => {
});
const container = document.createElement('div');
- const instance = ReactDOM.render(, container);
- const node = ReactDOM.findDOMNode(instance);
+ const root = ReactDOMClient.createRoot(container);
+ let node;
+ await act(() => {
+ root.render( (node = current)} />);
+ });
ReactTestUtils.Simulate.keyDown(node);
@@ -422,7 +488,7 @@ describe('ReactTestUtils', () => {
expect(event.nativeEvent.type).toBe('keydown');
});
- it('should work with renderIntoDocument', () => {
+ it('should work with renderIntoDocument', async () => {
const onChange = jest.fn();
class MyComponent extends React.Component {
@@ -435,7 +501,13 @@ describe('ReactTestUtils', () => {
}
}
- const instance = ReactTestUtils.renderIntoDocument();
+ const container = document.createElement('div');
+ const root = ReactDOMClient.createRoot(container);
+ let instance;
+ await act(() => {
+ root.render( (instance = current)} />);
+ });
+
const input = ReactTestUtils.findRenderedDOMComponentWithTag(
instance,
'input',
@@ -449,7 +521,7 @@ describe('ReactTestUtils', () => {
});
});
- it('should call setState callback with no arguments', () => {
+ it('should call setState callback with no arguments', async () => {
let mockArgs;
class Component extends React.Component {
componentDidMount() {
@@ -460,17 +532,28 @@ describe('ReactTestUtils', () => {
}
}
- ReactTestUtils.renderIntoDocument();
+ const container = document.createElement('div');
+ const root = ReactDOMClient.createRoot(container);
+ await act(() => {
+ root.render();
+ });
+
expect(mockArgs.length).toEqual(0);
});
- it('should find rendered component with type in document', () => {
+ it('should find rendered component with type in document', async () => {
class MyComponent extends React.Component {
render() {
return true;
}
}
- const instance = ReactTestUtils.renderIntoDocument();
+ const container = document.createElement('div');
+ const root = ReactDOMClient.createRoot(container);
+ let instance;
+ await act(() => {
+ root.render( (instance = current)} />);
+ });
+
const renderedComponentType = ReactTestUtils.findRenderedComponentWithType(
instance,
MyComponent,