Skip to content
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

Use async act in render (and all other helpers really) #222

Closed
ghost opened this issue Sep 19, 2019 · 7 comments
Closed

Use async act in render (and all other helpers really) #222

ghost opened this issue Sep 19, 2019 · 7 comments

Comments

@ghost
Copy link

ghost commented Sep 19, 2019

Describe the Feature

Since React and react-test-renderer 16.9.0 we have async act. This would be super helpful in the tests to remove all the act warnings and make a few tests pass that are failing otherwise

Possible Implementations

The easiest option would just be to update react-test-renderer and then making all act calls async by default. However, I'm not sure how that would work with downwards compatibility...

Related Issues

Would fix #176 and #200 which are both results of async act not being available

@ghost ghost added the feature request label Sep 19, 2019
@thymikee
Copy link
Member

We need some compat layer – checking whether react is at certain version or so

@SophieAu
Copy link

in the last two days, React Native updated to 0.61.1 which includes async act. Would be great if we could get it working in this library. From what I could tell, there's already an act helper file in the repo (https://github.com/callstack/react-native-testing-library/blob/master/src/act.js) that should cover the case of no act at all, however just wrapping that exported act in async should be possible without issues, right? If not, I'm happy to have a look and see if I can put together a PR.

@thymikee
Copy link
Member

A PR to support both regular and async act would be great!

@nielskrijger
Copy link

I'm working on a RN 0.59 project; updating 0.6X is a big change and we're tackling it one step at a time.
In our proces to ditch Enzyme we started migrating to this library. For us the main reason to use this library over https://www.npmjs.com/package/@testing-library/react-native was @testing-library/react-native requires async act which is only available in the newest RN versions.

I'm really happy to see wanting to support both for now has been on your mind 👍 Having a more gradual upgrade path is really helping us out.

@mav10
Copy link

mav10 commented Nov 8, 2019

I would join other guys about implementation of both variants.
We have updated to latest react and RN and are waiting for supporting this feature.

@brunohkbx
Copy link

Any updates on this?

@thymikee
Copy link
Member

thymikee commented Apr 17, 2020

Using async act won't magically fix your problems, because rendering is sync anyway and we won't await your render.
Please see this issue: #250 and this blog post https://kentcdodds.com/blog/fix-the-not-wrapped-in-act-warning to learn how to deal with act warnings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants