question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

Is your feature request related to a problem? Please describe. React 16.8 introduced act() to allow component interactions to be tested in a synchronous way.

Describe the solution you’d like wrapper.simulate() should be wrapped in act() to ensure any state changes are resolved before proceeding.

Describe alternatives you’ve considered

act(() => {
  wrapper.simulate();
});

Though it’s easy to forget act.

Additional context I have a feeling this is already on your roadmap, but I couldn’t find an issue about it.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:13 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
jquensecommented, May 3, 2019

@mikesteele let me know if you don’t have any time . i’d be happy to put something together as well

1reaction
mikesteelecommented, May 3, 2019

Thanks! I’ll try to find time to contribute. I think this will be a huge improvement for users who need to force wrappers to update after simulating events to ensure that state updates are complete.

Read more comments on GitHub >

github_iconTop Results From Across the Web

wrapper.simulate() should be wrapped in ReactTestUtils.act()
React 16.8 introduced act() to allow component interactions to be tested in a synchronous way. Describe the solution you'd like wrapper.simulate ...
Read more >
Test Utilities - React
ReactTestUtils makes it easy to test React components in the testing ... act(). To prepare a component for assertions, wrap the code rendering...
Read more >
Why do I need to wrap React/Enzyme state changes in act?
According to Enzyme's docs in most recent version mount() should be already wrapped with act() internally: If you're using React 16.8+ and ....
Read more >
React Testing Library and the “not wrapped in act” Errors
I recently upgraded React and React testing library. Very happy about the upgrade. But I start to see test errors like this: In...
Read more >
Why do I need to wrap React/Enzyme state changes in act?
If you're using React 16.8+ and .mount() , Enzyme will wrap apis including .simulate() , .setProps() , .setContext() , .invoke() with ReactTestUtils.act() ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found