testing-library / native-testing-library

🐳 Simple and complete React Native testing utilities that encourage good testing practices.
https://native-testing-library.com
MIT License
516 stars 44 forks source link

fix act warning on latest react native version v62 when running multiple tests #120

Closed sibelius closed 4 years ago

sibelius commented 4 years ago

this would be fixed on React 16.9.0, but it is still showing warnings on 16.11.0, related to this issue https://github.com/testing-library/native-testing-library/issues/25

this only happen when I have multiple it in the same test file

What you did:

tried to run all it tests of a single test file

What happened:

Warning: An update to MyComponent 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

Reproduction:

the component that is warning is using useMemo and useFormik (formik package)

Problem description:

it only warns when multiple tests is running

Suggested solution:

create a failing test showing the issue and fix it

Can you help us fix this issue by submitting a pull request?

not sure, where should I start?

mym0404 commented 4 years ago

I think this is not related to this library itself. The act warnning is in react testing library. You can read this kentcdodds article

thymikee commented 4 years ago

FYI, this repository is no longer responsible for this package. See the migration guide to v7.0 and check if it happens there.