-
Notifications
You must be signed in to change notification settings - Fork 232
wait and waitForValueToChange async utils #200
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
Conversation
Codecov Report
@@ Coverage Diff @@
## master #200 +/- ##
=====================================
Coverage 100% 100%
=====================================
Files 3 4 +1
Lines 56 95 +39
Branches 5 15 +10
=====================================
+ Hits 56 95 +39
Continue to review full report at Codecov.
|
I had a stab at this and it was actually way more complicated than I expected to flip the I did manage to refactor I've also been thinking about the name |
I've dragged my heels on this long enough on this. I've decided to take the names as they are now and we can always change them if better suggestions come along or if people don't understand them. |
What:
Added additional async utils:
wait(callback)
waitForValueToChange(selector)
Resolves #173
Why:
These additional utils privide similar to the
wait
andwaitForElement
/waitForElementToBeRemoved
from thedom-testing-library
async utils.This compliments the
waitForNextUpdate
utility we already provide that shares similarities to thewaitForDomChange
utility.How:
Theses utilities are layers on top of
waitForNextUpdate
, running their relevant checks on each rerender of the test component.I chose to be constsent with
dom-testing-library
by not pushing any values into the callbacks, but rather allow/expect the existing APIs to be used within them, this means testing for a value to change looks like:instead of
or something similar.
I anticipate this to cause some confusion when people first start using it so I have tried to call it out explicitly in the API reference docs. I have not made any changes to the usage docs yet as I want to get a feeling on what people are struggling with and how best to describe the intent and usage before making those changes.
I'm not super sold on the name of
waitForValueToChange
and may change it, so if you have any suggestions, I'd love to hear them.I'm also thinking about refactoring the implementation to have
wait
as the underlying utility instead ofwaitForNextUpdate
by proving a() => {}
callback towait
. I think this might make more conceptual sense to anyone else coming in and trying to understand how these all fir together.Checklist: