-
Notifications
You must be signed in to change notification settings - Fork 466
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
Add async/retryable findBy*
and findAllBy*
version of the queries
#203
Comments
Feel free to pull in https://github.com/alexkrolick/dom-testing-addon-async |
How has that lib been going @alexkrolick? Are you using it? Do you know of anyone else using it? What do you think? |
I used it in Puppeteer to simulate Cypress-like retries and it worked pretty well. The tricky part was more dealing with |
findBy*
and findAllBy*
version of the queriesfindBy*
and findAllBy*
version of the queries
I think that it's safe to say we can take a PR to add these queries. I may get to it eventually if nobody else does it first :) |
Hey @kentcdodds, I can give a try to this(most probably this weekend). |
What's the idea just copy over the files from the other repo? I can do that :D |
What other files/repo? |
Oh, no, this will be implemented as queries instead. Much better. |
Yeah, create named functions in queries.js. Don't use the custom wait either, use waitForElement. |
Ah okay, I will see if I find the time over the weekend/next week. If anyone wants to work on this don't hesitate to do so :) |
I'm working on this as I type this: https://www.youtube.com/watch?v=s0GLe81-9QY&index=2&list=PLV5CVI1eNcJgJCEkMlsqXea6OIF_uV_ub&t=0s |
🎉 This issue has been resolved in version 3.18.0 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
Describe the feature you'd like:
@alexkrolick has brought this up before and we ultimately decided to not go for it at the time, but I've been thinking about it more and I think it's time to revisit the decision.
There are some UI frameworks that are completely async. In my TestingJavaScript.com course when I show how to use dom-testing-library with these, I had to create a
fire-event-async.js
file to deal with those, but that wasn't enough for mithril's tests because mithril does not re-render on the next tick all the time (for who knows what reason 🤷♂️).The
findBy*
andfindAllBy*
variants of the queries would return promises that resolve when the query is satisfied, or timeout after 3500ms or so.Suggested implementation:
I'm thinking it'd be something like this:
Describe alternatives you've considered:
So far the alternative is to have people write this themselves:
That's worked pretty well most of the time, but I think it would be nicer to write that like this:
Teachability, Documentation, Adoption, Migration Strategy:
We do have query explosion going on and I think the docs could be improved slightly around this to document first the types of queries (label text, text, placeholder, etc), and then the variants (
getBy*
,queryAllBy*
, etc.).This would be a new feature, so no breaking change/migration strategy necessary.
The text was updated successfully, but these errors were encountered: