sapegin/enzyme-article-2019

React act() warnings

Closed this issue · 6 comments

See this in each RemotePizza_*.spec.js test and have no idea where should I put act() calls:

    console.error node_modules/react-dom/cjs/react-dom.development.js:545
      Warning: An update to RemotePizza inside a test was not wrapped in act(...).

      When testing, code that causes React state updates should be wrapped into act(...):

      act(() => {
        /* fire events that update state */
      });
      /* assert on the output */

      This ensures that you're testing the behavior the user would see in the browser. Learn more at https://fb.me/react-wrap-tests-with-act
          in RemotePizza (created by WrapperComponent)
          in WrapperComponent

This one works but it throws a different error about the act version`:
It works
https://codesandbox.io/s/enzyme-jest-example-z5eo0

Hm, what did you change?

Put everything inside the act

Ufff ;-/

Also made it async, check Hello.test.js

Fixed by #2.