From d19e57f7cb86056f81b4af3a4a95565f57355672 Mon Sep 17 00:00:00 2001 From: Jubayeromi Date: Fri, 30 Oct 2026 15:46:31 +0600 Subject: [PATCH 1/3] Document testing cleanup --- src/content/warnings/react-dom-test-utils.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/content/warnings/react-dom-test-utils.md b/src/content/warnings/react-dom-test-utils.md index 794bb1d11f4..48032ee9d96 100644 --- a/src/content/warnings/react-dom-test-utils.md +++ b/src/content/warnings/react-dom-test-utils.md @@ -43,6 +43,16 @@ import {render} from '@testing-library/react'; render(); ``` +`render` returns an `unmount` function and the rendered container: + +```js +const {unmount, container} = render(); + +unmount(); +expect(container.innerHTML).toBe(''); +``` + + ### ReactDOMTestUtils.Simulate {/*reactdomtestutilssimulate*/} From 9293f4a871ef4a5c0b34aac805afa5441b4b4f16 Mon Sep 17 00:00:00 2001 From: Jubayeromi Date: Fri, 30 Oct 2026 15:47:28 +0600 Subject: [PATCH 2/3] Document testing cleanup --- src/content/warnings/react-dom-test-utils.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/content/warnings/react-dom-test-utils.md b/src/content/warnings/react-dom-test-utils.md index 48032ee9d96..515bae6f89d 100644 --- a/src/content/warnings/react-dom-test-utils.md +++ b/src/content/warnings/react-dom-test-utils.md @@ -52,7 +52,7 @@ 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*/} From c0d82b985df14119b08a9b5d6c3235d4aeae3a1d Mon Sep 17 00:00:00 2001 From: Jubayeromi Date: Fri, 30 Oct 2026 15:49:53 +0600 Subject: [PATCH 3/3] Document testing cleanup --- src/content/warnings/react-dom-test-utils.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/content/warnings/react-dom-test-utils.md b/src/content/warnings/react-dom-test-utils.md index 515bae6f89d..57a55399523 100644 --- a/src/content/warnings/react-dom-test-utils.md +++ b/src/content/warnings/react-dom-test-utils.md @@ -43,6 +43,7 @@ import {render} from '@testing-library/react'; render(); ``` + `render` returns an `unmount` function and the rendered container: ```js @@ -54,6 +55,7 @@ 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`.