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

Wrap render calls with act() for better Hooks integration #111

Closed
thymikee opened this issue Feb 6, 2019 · 2 comments
Closed

Wrap render calls with act() for better Hooks integration #111

thymikee opened this issue Feb 6, 2019 · 2 comments
Assignees

Comments

@thymikee
Copy link
Member

thymikee commented Feb 6, 2019

Hooks work fine even without it, but you'll likely need to add asynchrony to your code. With act() you'll be able to achieve the same results in synchronous manner.

See: https://reactjs.org/blog/2019/02/06/react-v16.8.0.html#testing-hooks

@ccfz
Copy link

ccfz commented Mar 19, 2019

It would be great if update is also be wrapped with act().

@Esemesek
Copy link
Collaborator

@ccfz Would appreciate a PR with an example test for this functionality.

ccfz added a commit to ccfz/react-native-testing-library that referenced this issue Apr 3, 2019
To test behaviour that only occurs when props are updated it is
necessary to call update on the test instance. However, if the
behaviour under test is triggered by a hook, e.g. useEffect then
the test will fail because the hook is only triggered after the test
has run.

This addresses the issue by wrapping the update function with act().

callstack#111
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

3 participants