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 mounts simulate() in ReactTestUtils.act() #2135

Merged
merged 1 commit into from
May 24, 2019

Conversation

petersendidit
Copy link
Contributor

Wraps the mount simulate method in ReactTestUtils.act() to correctly
allow component interactions to be tested in a synchronous way

Fixes #2084

…Utils.act()

Wraps the mount simulate method in ReactTestUtils.act() to correctly
allow component interactions to be tested in a synchronous way

Fixes enzymejs#2084
Copy link
Member

@ljharb ljharb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Moved the test to simulate.jsx so it could eventually run for both shallow and mount.

@ljharb ljharb merged commit aedb208 into enzymejs:master May 24, 2019
@petersendidit petersendidit deleted the SimulateAct branch May 24, 2019 12:25
ljharb added a commit that referenced this pull request May 26, 2019
 - [fix] ensure the correct displayName for `memo` components (#2137)
 - [fix] `mount`: wrap simulate() in ReactTestUtils.act() (#2135)
 - [fix] properly handle `memo`’s `areEquals` arg (#2128)
 - [dev deps] update `eslint-plugin-import`
 - [deps] update `semver`
@shakedClio
Copy link

Hey @ljharb, which approach would you recommend to use for hooks (when I am using mount)?

  1. wrapper.find('.Button').simulate('click');
ReactTestUtils.act(() => {
  wrapper.find('.Button').prop('onClick')();
});

I’ve seen you recommend against using simulate in other comments before, so I was just looking for clarification if you still feel this way.

@ljharb
Copy link
Member

ljharb commented Jun 6, 2019

The second, for sure :-)

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

Successfully merging this pull request may close these issues.

wrapper.simulate() should be wrapped in ReactTestUtils.act()
3 participants