-
Notifications
You must be signed in to change notification settings - Fork 274
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
tests with waitFor
or findBy
only pass with concurrentRoot: false
#1749
Comments
I'm experiencing the same issue after the recent upgrade to react-native |
I've run your tests inside RNTL test suit and it passed fine for both React 0.77.1 and 0.78. The same when adding the test cases to So most probably this is some setup inside your app that is messing the test. @gfreeman-karmak, @flaviomsb If you believe this is an issue with RNTL could you provide a minimal repro repository? |
@mdjastrzebski Thanks for the reply. I've been looking into our setup this morning, and I've found the issue is that we call Specifically if fake timers are in play when the I haven't found exactly why that's problematic, but in the end it wasn't good practice on our part to use fake timers that early in the process. We need to do that just before the tests run, so moving |
We're having an odd issue since upgrading to v13. We had a lot of tests suddenly break, and they were all tests that depended on
waitFor
, whether using it directly or using afindBy
query. For some reason when thewaitFor
loop advances jest timers, the screen is no longer updating, so expectations and queries never resolve.What I found fixed the issue for now is to set
concurrentRoot: false
, but that can only be temporary until react v19.Interestingly, I also tried editing the
wait-for.js
code directly to wrapjest.advanceTimersByTime(interval);
inact
and that also worked. However it appearsIS_REACT_ACT_ENVIRONMENT
is purposely set to false, so I have to assume the omission ofact
is intentional, so I don't understand whyconcurrentRoot: true
would suddenly break the tests.I wrote a small test to illustrate:
The test with
concurrentRoot: false
passes with no issue, but in theconcurrentRoot: true
test,findBy
never finds the button:Unable to find an element with role: button
.Any ideas?
react: 18.3.1
react-native: 0.77.0
react-test-renderer: 18.3.1
@testing-library/react-native: 13.0.1
jest: 29.7.0
Thanks
The text was updated successfully, but these errors were encountered: