testing-library / testing-library/testing-library-docs

Document confusing behavior with waitForElementToBeRemoved

Open
#409 7 comments 0 reactions 0 assignees View on GitHub

@shermanhui is already working on this.

Since Oct 23, 2020.

  • #652 by @shermanhui — open
help wanted 👋
Dominant language
JavaScript
Stars
479
Forks
740
PR merge metrics
No merged PRs in 30d

Description

So, I added this feature:

- await waitForElementToBeRemoved(() => screen.getByText('foo'))

+ const element = screen.getByText('foo')
+ await waitForElementToBeRemoved(element)

Both work, but the first I think is easier most of the time.

But I just learned that in React applications (and likely other frameworks) the DOM nodes aren't always removed, rather they're updated. So, that cool new feature won't always work as you might expect. I think we should probably document this somewhere.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the documentation for waitForElementToBeRemoved and review how its callback and element forms are currently described. Document that framework updates may change or reuse DOM nodes instead of removing them, and confirm the examples clearly explain when each form works.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, react
Domain
documentation, testing
Issue type
Documentation
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.