Skip to content
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

Behavior of waitForElementToBeRemoved when first call throws #1093

Open
make-github-pseudonymous-again opened this issue Jan 21, 2022 · 1 comment · May be fixed by #1094
Open

Behavior of waitForElementToBeRemoved when first call throws #1093

make-github-pseudonymous-again opened this issue Jan 21, 2022 · 1 comment · May be fixed by #1094

Comments

@make-github-pseudonymous-again
Copy link

  • @testing-library/dom version: 8.11.2

Problem description:

There is currently no exception catching for the initial call inside waitForElementToBeRemoved. When that call of callback throws, instead of getting the error Error('The element(s) given to waitForElementToBeRemoved are already removed...') we will get the error thrown from the callback, even when it is a TestingLibraryElementError. This contradicts the documented behavior:

waitForElementToBeRemoved(() => getByText(/not here/i)).catch(err =>
  console.log(err),
)
// Error: The element(s) given to waitForElementToBeRemoved are already removed. waitForElementToBeRemoved requires that the element(s) exist(s) before waiting for removal.

Suggested solution:

See #1094.

make-github-pseudonymous-again added a commit to contribulate/dom-testing-library that referenced this issue Jan 21, 2022
@eps1lon
Copy link
Member

eps1lon commented Jan 25, 2022

This contradicts the documented behavior:

The documentation is contradicting itself already. It only says that it'll throw on null or empty arrays. But it doesn't say that () => null will throw. However, it later includes waitForElementToBeRemoved(() => getByText(/not here/i)) in the examples.

So documentation should be clarified as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants