-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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 mount renderer render with reactTestUtils.act() #2034
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, this is great!
4926f6e
to
35ec8fb
Compare
@chenesan : Glad to see this PR merged. |
@chenesan @ljharb Can we implement same changes for ShallowRenderer too considering facebook/react#15120 ? Please correct me if my understanding is wrong. |
@pgangwani I had to revert the act-wrapping in shallow because it requires a DOM, which shallow must not. |
@ljharb Got it. Main intension was to know if there is impact after facebook/react#15120 is merged. |
Flush any effects scheduled with `useEffect` using the `act` helper on the initial render. This means that in a test a developer can write: ``` const wrapper = mount(<ComponentThatUsesEffects/>) ``` And know that effects will have been run before they start interacting with the result wrapper. See enzymejs/enzyme#2034 for corresponding change to the React adapter.
This PR wrap the render function of mount renderer with
act()
so that use cases withuseEffect
would work. The test is the test case in https://github.com/threepointone/react-act-examples/blob/master/README.md#effects .