Skip to content

docs: update waitForElementToBeRemoved #652

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
8 changes: 6 additions & 2 deletions docs/dom-testing-library/api-async.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,12 @@ To wait for the removal of element(s) from the DOM you can use
`waitForElementToBeRemoved`. The `waitForElementToBeRemoved` function is a small
wrapper around the `waitFor` utility.

The first argument must be an element, array of elements, or a callback which
returns an element or array of elements.
The first argument must be a callback which returns an element or array of
elements, an element, or an array of elements. The recommended approach is to
use a callback that returns an element or array of elements. This is because DOM
nodes aren't guaranteed to be removed but rather updated in frameworks such as
React. This could lead to unexpected results when passing an element or array of
elements as the element is not actually removed, but instead updated.

Here is an example where the promise resolves because the element is removed:

Expand Down