Skip to content

using waitFor and find* queries throwing TestRenderer.act errors #798

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

Closed
millibeckers opened this issue Aug 18, 2021 · 3 comments
Closed
Labels
question Further information is requested

Comments

@millibeckers
Copy link

I am unable to use any of the find* queries in my tests, and I cannot get waitFor or act to work either. I haven't found any other instances of this error online. I can reproduce this issue using the exact code posted in this comment on a similar issue.

I have checked that I am not using jest.useFakeTimers anywhere.

Versions being used:
react-native: 0.61.5
react: 16.9.0
@testing-library/react-native: 7.2.0

I am getting the following error:

  console.error
    Warning: The callback passed to TestRenderer.act(...) function must not return anything.
    
    It looks like you wrote TestRenderer.act(async () => ...) or returned a Promise from it's callback. Putting asynchronous logic inside TestRenderer.act(...) is not supported.
    

      at warningWithoutStack$1 (node_modules/react-test-renderer/cjs/react-test-renderer.development.js:102:32)
      at act (node_modules/react-test-renderer/cjs/react-test-renderer.development.js:13176:9)
      at call (node_modules/@testing-library/react-native/build/waitFor.js:69:9)
      at tryCatch (node_modules/regenerator-runtime/runtime.js:63:40)
      at Generator._invoke (node_modules/regenerator-runtime/runtime.js:293:22)
      at Generator.call (node_modules/regenerator-runtime/runtime.js:118:21)
      at tryCatch (node_modules/regenerator-runtime/runtime.js:63:40)

  console.error
    Warning: Do not await the result of calling TestRenderer.act(...), it is not a Promise.

      at warningWithoutStack$1 (node_modules/react-test-renderer/cjs/react-test-renderer.development.js:102:32)
      at Object.then (node_modules/react-test-renderer/cjs/react-test-renderer.development.js:13185:11)
@millibeckers millibeckers added the question Further information is requested label Aug 18, 2021
@millibeckers
Copy link
Author

I posted this issue in case someone else ever has the same problem as I did.

The problem turned out to be that I had my version of react-test-renderer set explicitly to 16.8.6 in my package.json. Updated that to 16.9.0 to match the react version and it's now working as expected.

@mharrison-nzme
Copy link

mharrison-nzme commented Sep 12, 2022

Just writing to say this helped me out, matching the renderer version to my react version. Thank you

@mdjastrzebski
Copy link
Member

@mharrison-nzme thanks for sharing this.

In case of trouble you should also check if your React Native version matches React version, as this two packages are different versioning schemes you can use e.g. React Native Upgrade Helper to find a proper version match.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants