-
Notifications
You must be signed in to change notification settings - Fork 273
Warning: You called act(async () => ...) without await. 2 minute repro on examples/reactnavigation #859
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
Comments
I believe this happens when calling several times await findByText in a row though I'm not sure why. In this example the tests don't need to be asynchronous so removing async and using getBy instead of findBy works fine and it makes the warning go away. I also think it's a bad pattern to use findByText by default and to make all tests asynchronous when it is not necessary, so I'd recommend either changing the example so that we really need to use waitfor in the tests or using plain getByText |
The thing is @pierrezimmermannbam that when you actually need to use findBy (or any kind of await for async operation) twice in the same test, you'll always have the warning. |
@teves-castro it seems to be linked to Promise being overridden by react native preset. Not sure wether this can be fixed but using rntl preset which restores original Promise fixes the warning for me. Bumping the version of rntl and using the preset also fixes the warning in the example repo |
I am not sure what exactly causes the async |
Closing as the error no longer occurs when running tests in |
Describe the bug
I see the infamous
Warning: You called act(async () => ...) without await.
after a fresh clone and install checking out thereactnavigation
example.Expected behavior
No warnings. I thought
react-native-testing-library
is supposed to wrap all async actions inact
already? I guess and useawait
Steps to Reproduce
git clone https://github.com/callstack/react-native-testing-library.git
cd react-native-testing-library/examples/reactnavigation
npm install
(You neednpm install --legacy-peer-deps
if you are using a newer version of Node)npm run test
Versions
The text was updated successfully, but these errors were encountered: