Wrap mount renderer render with reactTestUtils.act()#2034
Merged
Conversation
This was referenced Mar 6, 2019
ljharb
requested changes
Mar 7, 2019
ljharb
force-pushed
the
react-test-util-act
branch
2 times, most recently
from
March 10, 2019 07:05
4926f6e to
35ec8fb
Compare
|
@chenesan : Glad to see this PR merged. |
|
@chenesan @ljharb Can we implement same changes for ShallowRenderer too considering react/react#15120 ? Please correct me if my understanding is wrong. |
Member
|
@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 react/react#15120 is merged. |
This was referenced Apr 5, 2019
robertknight
added a commit
to preactjs/enzyme-adapter-preact-pure
that referenced
this pull request
Apr 14, 2019
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 file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR wrap the render function of mount renderer with
act()so that use cases withuseEffectwould work. The test is the test case in https://github.com/threepointone/react-act-examples/blob/master/README.md#effects .