react-testing: Introduce a waitFor helper #2536
Labels
Area: testing
Package: react-testing
Type: Feature Request 🙌
Request a new feature or changes to an existing one
Overview
Relates to: https://github.com/Shopify/pos-channel/issues/9692
It looks like there is no clean way to test certain use cases that involve some state update scenarios within
useEffect
. Here is a minimal example.react-testing-library
offers awaitFor
method for cases like these. Here is a naive implementation that takes us a bit further.And the same test using the above helper
The above test passes, but it still feels a bit dirty considering React fires
act
warnings:Would appreciate some insights on how we could best support this.
References:
Type
Motivation
...
Area
Area: <area>
labels to this issueScope
Is this issue related to a specific package?
Package: <package_name>
label.Is it related to a new package?
New package
LabelChecklist
The text was updated successfully, but these errors were encountered: