Skip to content

Commit e28fcc5

Browse files
committed
Add warning page for ReactDOMTestUtils deprecation
1 parent 4df3124 commit e28fcc5

File tree

1 file changed

+63
-0
lines changed

1 file changed

+63
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
---
2+
title: react-dom/test-utils Deprecation Warnings
3+
---
4+
5+
## ReactDOMTestUtils.act() warning {/*reactdomtestutilsact-warning*/}
6+
7+
`act` from `react-dom/test-utils` has been deprecated in favor of `act` from `react`:
8+
9+
```diff
10+
-import {act} from 'react-dom/test-utils';
11+
+import {act} from 'react';
12+
```
13+
14+
## Rest of ReactDOMTestUtils APIS {/*rest-of-reactdomtestutils-apis*/}
15+
16+
All APIs except `act` have been removed.
17+
18+
The React Team recommends migrating your tests to [@testing-library/react](https://testing-library.com/docs/react-testing-library/intro/) for a modern and well supported testing experience.
19+
20+
### ReactDOMTestUtils.renderIntoDocument {/*reactdomtestutilsrenderintodocument*/}
21+
22+
`renderIntoDocument` can be replaced with `render` from `@testing-library/react`:
23+
24+
```diff
25+
-import {renderIntoDocument} from 'react-dom/test-utils';
26+
+import {render} from '@testing-library/react';
27+
28+
-renderIntoDocument(<Component />);
29+
+render(<Component />);
30+
```
31+
32+
### ReactDOMTestUtils.Simulate {/*reactdomtestutilssimulate*/}
33+
34+
`Simulate` can be replaced with `fireEvent` from `@testing-library/react`.
35+
36+
```diff
37+
-import {Simulate} from 'react-dom/test-utils';
38+
+import {fireEvent} from '@testing-library/react';
39+
40+
const element = document.querySelector('button');
41+
-Simulate.click(element);
42+
+fireEvent.click(element);
43+
```
44+
45+
Be aware, that `fireEvent` dispatches an actual event on the element and doesn't just synthetically call the event handler.
46+
47+
### List of all removed APIs /*list-of-all-removed-apis*/
48+
49+
- `mockComponent()`
50+
- `isElement()`
51+
- `isElementOfType()`
52+
- `isDOMComponent()`
53+
- `isCompositeComponent()`
54+
- `isCompositeComponentWithType()`
55+
- `findAllInRenderedTree()`
56+
- `scryRenderedDOMComponentsWithClass()`
57+
- `findRenderedDOMComponentWithClass()`
58+
- `scryRenderedDOMComponentsWithTag()`
59+
- `findRenderedDOMComponentWithTag()`
60+
- `scryRenderedComponentsWithType()`
61+
- `findRenderedComponentWithType()`
62+
- `renderIntoDocument`
63+
- `Simulate`

0 commit comments

Comments
 (0)