Skip to content

Conversation

shermanhui
Copy link
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
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

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

Labels

None yet

3 participants