Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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
shermanhui wants to merge 1 commit into testing-library:main
base: main
Choose a base branch
Loading
from shermanhui:document-confusing-behavior-for-waitForElementToBeRemoved

Conversation

Copy link
Contributor

@shermanhui shermanhui commented Oct 23, 2020

I've added clarification that a callback function is the recommended argument type to be passed into the callback argument of waitForElementToBeRemoved. As DOM nodes are not guaranteed to be removed in frameworks such as React; They may be updated rather than removed as referenced in issue #409.

I'd like to add a vanilla JS example in the following md file, but I'm not sure how to replicate the issue that was described in the issue thread, and I'd appreciate any assistance with getting some working examples to add to the docs!

I have a sandbox up here with a Vanilla JS example here, but I'm not sure how to test the text change (AFAIK - it should work as expected, it's
essentially the same logic as the React example).

I also have a React example here, where I was trying to reproduce the failing case that @kentcdodds reported here in order to add an example of the failure that was mentioned.

The second test case is where I pass an element directly instead of a callback, but it seems like this case passes 🤔

Add clarification that a callback function is the recommended
argument type to be passed into the `callback` argument of
`waitForElementToBeRemoved` as DOM nodes are not
guaranteed to be removed in frameworks such as React. They
may be updated rather than removed as referenced in issue testing-library#409.
Copy link
Member

@kentcdodds kentcdodds left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent 👍

Copy link

kentr commented Oct 25, 2020

I couldn't figure out how to comment on the commit itself, so I'm putting this here.

I suggest a slight variation in the first 2 lines of the change by @shermanhui. The difference is the order in which the options are listed:

- 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
+ The first argument must be an element, an array of elements, or a callback
+ which returns an element or array of elements, . The recommended approach is to

@nickserv nickserv linked an issue Nov 9, 2020 that may be closed by this pull request
nikkhielseath added a commit to nikkhielseath/testing-library-docs that referenced this pull request Apr 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Reviewers

@kentcdodds kentcdodds kentcdodds approved these changes

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

Document confusing behavior with waitForElementToBeRemoved

AltStyle によって変換されたページ (->オリジナル) /