Skip to content

Commit 169020f

Browse files
committed
No diff syntax highlighting available
1 parent a19311b commit 169020f

File tree

1 file changed

+39
-15
lines changed

1 file changed

+39
-15
lines changed

src/content/warnings/react-dom-test-utils.md

Lines changed: 39 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,18 @@ title: react-dom/test-utils Deprecation Warnings
44

55
## ReactDOMTestUtils.act() warning {/*reactdomtestutilsact-warning*/}
66

7-
`act` from `react-dom/test-utils` has been deprecated in favor of `act` from `react`:
7+
`act` from `react-dom/test-utils` has been deprecated in favor of `act` from `react`.
88

9-
```diff
10-
-import {act} from 'react-dom/test-utils';
11-
+import {act} from 'react';
9+
Before:
10+
11+
```js
12+
import {act} from 'react-dom/test-utils';
13+
```
14+
15+
After:
16+
17+
```js
18+
import {act} from 'react';
1219
```
1320

1421
## Rest of ReactDOMTestUtils APIS {/*rest-of-reactdomtestutils-apis*/}
@@ -19,27 +26,44 @@ The React Team recommends migrating your tests to [@testing-library/react](https
1926

2027
### ReactDOMTestUtils.renderIntoDocument {/*reactdomtestutilsrenderintodocument*/}
2128

22-
`renderIntoDocument` can be replaced with `render` from `@testing-library/react`:
29+
`renderIntoDocument` can be replaced with `render` from `@testing-library/react`.
2330

24-
```diff
25-
-import {renderIntoDocument} from 'react-dom/test-utils';
26-
+import {render} from '@testing-library/react';
31+
Before:
2732

28-
-renderIntoDocument(<Component />);
29-
+render(<Component />);
33+
```js
34+
import {renderIntoDocument} from 'react-dom/test-utils';
35+
36+
renderIntoDocument(<Component />);
37+
```
38+
39+
After:
40+
41+
```js
42+
import {render} from '@testing-library/react';
43+
44+
render(<Component />);
3045
```
3146

3247
### ReactDOMTestUtils.Simulate {/*reactdomtestutilssimulate*/}
3348

3449
`Simulate` can be replaced with `fireEvent` from `@testing-library/react`.
3550

36-
```diff
37-
-import {Simulate} from 'react-dom/test-utils';
38-
+import {fireEvent} from '@testing-library/react';
51+
Before:
52+
53+
```js
54+
import {Simulate} from 'react-dom/test-utils';
55+
56+
const element = document.querySelector('button');
57+
Simulate.click(element);
58+
```
59+
60+
After:
61+
62+
```js
63+
import {fireEvent} from '@testing-library/react';
3964

4065
const element = document.querySelector('button');
41-
-Simulate.click(element);
42-
+fireEvent.click(element);
66+
fireEvent.click(element);
4367
```
4468

4569
Be aware, that `fireEvent` dispatches an actual event on the element and doesn't just synthetically call the event handler.

0 commit comments

Comments
 (0)