-
Notifications
You must be signed in to change notification settings - Fork 232
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
wait
not triggered on non hook updates
#393
Comments
Hi @AugustinLF, You're correct, the implementation between the two is different. This is the second issue (this was the first) now where that decision seems to be causing confusion and/or problems. This issue feels like a more compelling argument for making the change than previously, so I'm happy to explore the idea in more detail. Essentially, all the other async utils are build on top of
The checks for The intended use case for I think it also makes sense for My biggest concern is if two renders occur between intervals that change the value and change it back again, that the change will be missed and the test will time out. I'm not sure how possible it would be to trigger the check on an interval or when the hook renders, essentially giving the best of both worlds? Finally, Happy to hear any thoughts or counter points to any of this. I'm definitely not attached to the existing implementations or any of these specific ideas, so feel free throw it all away and think about it from a fresh slate. |
What you wrote makes a lot of sense, and I don't see any issue with it. You're right about the risk of the conflict between intervals and updates, but I feel like that would be an ok deal. If people really care about catching all the different states of the hook, they would probably use |
Describe the feature you'd like:
wait
fromasyncUtilities
is only called when the hooks updates, and can't be used to check on side-effects. As far as I know, this is different from the behaviour of thewait
exposed from@testing-library/dom
or the one of@testing-library/react-native
which to me was very confusing.I have a hook that does some async work, then dispatches a redux action. I was doing a
await wait(() => expect(store.dispatch).toHaveBeenCalled())
. My test never resolved, replacing thewait
fromrenderHook
to the one exported in@testing-library/react
made my test pass.Suggested implementation:
I didn't look enough to the implementation of these two libraries' wait, but perhaps something similar could be made? I would be totally ok with contributing and opening such a PR if you're ok.
Teachability, Documentation, Adoption, Migration Strategy:
There shouldn't be any change of API, and this would not be a breaking change, so I guess this wouldn't be ok?
The text was updated successfully, but these errors were encountered: