Tests with async useEffect don't seem to complete
See original GitHub issueDescribe the bug
So I guess this is on the back of my question (https://github.com/callstack/react-native-testing-library/issues/1066) where I was trying to reproduce and isolate the issue. However, I have come up against something similar.
Repo: https://github.com/leepowelldev/rntl-async-bug
I have created a new component MyComponent
which has three useEffects which consume async methods (each has appropriate cleanup functions). The test waits for these effects to run, and then assert the final rendered text. However, this never succeeds and the text can never be found. It seems to hang on the second useEffect and the test times out - resulting in the component being unmounted.
Expected behavior
Test should pass and should be able to find ‘Hello world.’ - this works as expected in simulator with no errors.
Steps to Reproduce
Clone repo, install deps and run npm test
or yarn test
Screenshots
Versions
npmPackages: @testing-library/react-native: ^11.0.0 => 11.0.0 react: 18.0.0 => 18.0.0 react-native: 0.69.4 => 0.69.4 react-test-renderer: 18.0.0 => 18.0.0
Issue Analytics
- State:
- Created a year ago
- Comments:9 (3 by maintainers)
Top GitHub Comments
@mdjastrzebski sorry, this was on my “todo” list, but it’s been a busy few days and it slipped my mind. Thanks for the fix and for testing 🙇
Closing as fixed.
@leepowelldev If the issue still occurs for you on the latest version of RNTL, please provide update the repo with latest RNTL, React, etc deps so that we are able to reproduce it on our end.