-
Notifications
You must be signed in to change notification settings - Fork 470
waitForElementToDisappear #206
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
Comments
Could you open this issue in dom-testing-library? That's where this work will be done. I'm thinking I'm in favor. |
@kentcdodds I think there's a new GitHub feature that allows owners of a repo to transfer issues to other repos. Can you check if that's the case here? |
Forgot about that! Done :) Now let's discuss. So you can do this today with: await wait(() => expect(getByText('my button')).not.toBeInTheDocument()) But that's kinda awkward and having a |
In the meantime, I found out that |
I'm into it. I say let's do it. |
@kentcdodds I think it would have to be queryByText? Otherwise the getByText itself will fail when the element goes away, and the expectation won't be checked. edited: I typed it a while ago, and when I commented I saw that you already decided to do it - not trying to argue here, just curious :) |
No worries @lgandecki, thanks for providing your perspective. You make good points. I wonder though if there could be several document changes before that thing is actually removed. Like a progress bar for example. It's true that this is really not a very typical thing and the workaround isn't that challenging (you're right, would need to be a |
@kentcdodds @lgandecki I stumbled upon this issue and myself today, I need to check a progress loader has finished, as the main list element to check is always in the dom, I could check individual items within the list element but wanted to give this a try and then use snapshots for asserting that the items are there.
but as stated that fails as the getByTestId fails when the loader is done.
but now I get EDIT:
|
@gabriel403 jest-dom was just updated today to not throw when .toBeInTheDocument is checked against |
This should be closed now the PR was merged and released! |
Describe the feature you'd like:
I love the
waitForElement
function. However, there are cases where I don't add an element but rather remove existing ones. Is there a similarwaitForElementToDisappear
function or is there an easy way to achieve that using the existing functions?Suggested implementation:
Currently I'm using
process.nextTick
but that seems like a hack to me:The text was updated successfully, but these errors were encountered: