wait and waitForValueToChange async utils#200
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
waitandwaitForElement/waitForElementToBeRemovedfrom thedom-testing-libraryasync utils.This compliments the
waitForNextUpdateutility we already provide that shares similarities to thewaitForDomChangeutility.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-libraryby 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
waitForValueToChangeand 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
waitas the underlying utility instead ofwaitForNextUpdateby 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: