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: add asyncWrapper config
Why: At first glance you're probably thinking: "Oh no, no no. No way." But think for a moment that react-testing-library can't just export its own
wait*
APIs and make everything work, because thefindBy*
queries all use thewaitForElement
API that's exposed by dom-testing-library (not the one that would be wrapped by react-testing-library), so we have two options:findBy*
query that exists today and keep that updated in the future if new queries are ever added. This would include wrappingwithin
/getQueriesForElement
so thefindBy*
queries from those are are wrapped. In addition to wrapping all thewait*
utilities.wait*
APIs as this PR doesI don't like either of those solutions, but I dislike solution 2 WAY less.
How:
Add a config option called
asyncWrapper
and wrap all thewait*
APIs in that. The default just calls the callback so there's no real cost to doing it this way. I've tested this locally with and without my changes to react-testing-library and it works great (so people using a new dom-testing-library and an old react-testing-library will be fine). When I update react-testing-library I'll make sure to add a version bump to dom-testing-library so we don't wind up with the opposite situation.Checklist: