Skip to content
Open
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
12 changes: 12 additions & 0 deletions src/content/warnings/react-dom-test-utils.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,18 @@ import {render} from '@testing-library/react';
render(<Component />);
```

`render` returns an `unmount` function and the rendered container:

```js
const {unmount, container} = render(<Component />);

unmount();
expect(container.innerHTML).toBe('');
```

React Testing Library automatically cleans up rendered trees after each test when your test framework provides an `afterEach` hook. You can call `unmount` yourself when you need to verify cleanup during a test. Unmounting a tree also removes content rendered into a portal by that tree. If your test creates a separate React root, unmount that root separately.

``
### ReactDOMTestUtils.Simulate {/*reactdomtestutilssimulate*/}

`Simulate` can be replaced with `fireEvent` from `@testing-library/react`.
Expand Down
Loading