Skip to content

docs: update waitForElementToBeRemoved#652

Draft
shermanhui wants to merge 1 commit intotesting-library:mainfrom
shermanhui:document-confusing-behavior-for-waitForElementToBeRemoved
Draft

docs: update waitForElementToBeRemoved#652
shermanhui wants to merge 1 commit intotesting-library:mainfrom
shermanhui:document-confusing-behavior-for-waitForElementToBeRemoved

Conversation

@shermanhui
Copy link
Copy Markdown
Contributor

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
Copy Markdown
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 👍

@kentr
Copy link
Copy Markdown

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Document confusing behavior with waitForElementToBeRemoved

3 participants