wait and waitForValueToChange async utils #200
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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: