tl;dr, in order for Detox RN sync future proof, we need to define a public API in React Native so Detox's Idling Resources can query in runtime -or- we can create IdlingResources inside React Native itself and hook them up in Detox.
The current state of Detox for Android is that we only support React Native <=51.
Detox uses Espresso to sync with React Native if it exists inside the app, and we have multiple IdlingResources listening on various loopers/events/object states.
The main issue we have now, is that we did all that using reflection, as most of the things we listen on have no public APIs.
I want to suggest that we add public API to RN, or add public Idling Resources to RN, so synchronization never breaks and we get better testing performance by using callback based state change instead of polling with isIdleNow.
These are the current IdlingResources we're using to sync with RN <=51:
ReactBrideIdlingResource.java - this one is actually using public API (though it uses reflection to register a callback anyway, but we will change that). I think we already have everything we need here.
ReactNativeTimersIdlingResource.java - this IdlingResource polls the size of mTimers in com.facebook.react.modules.core.Timing Native module, to make sure espresso won't execute an action if a there's a timer about to expire. We would probably need to add some sort of public function we can call to make sure there are no timers about to expire in a given timeframe.
RNExperimentalNetworkIR - This one is pretty easy to wing, since RN uses OKHttp, we can just use the original IdlingResource supplied by OKHttp (we can customize it and add our blacklist functionality. The only thing we need is access to mClient. This is how we do it today
AnimatedModuleIdlingResource.java - I think this one is pretty easy:
NativeAnimatedNodesManager has the public API hasActiveAnimations but the instance is not public in NativeAnimatedModule
ReactNativeUIModuleIdlingResource - this is the trickest one. The current sync is not 100%, I would like to somehow get an event when React knows it finished rendering. Is it possible ?
Today we're using getInstanceManager().addReactInstanceEventListener() , but for some reason, sometimes, this callback is never called (probably because RN has already finished loading before the callback was registered (?)). We should reiterate on this one and see what has changed in modern RN.
We need to make sure this public API won't break, and make sure its treated as such.
Are these the items needed to support the latest versions of RN? It seems silly that Android support work has just started but doesn't support the latest versions of React Native.
Added a tl;dr.
We (Wix) are discussing with the RN team a way to make Detox work with next versions of RN in a more sane and future proof way.
It's actually out since React Native 44, and getting it to 56 is being worked on currently.
The purpose of this thread is to discuss how this can be integrated with RN itself, so it will be supported on every version, regardless of internal changes in private RN APIs.
The link to RNExperimentalNetworkIR is broken. Did the file in question disappear?
Is the current version of Detox compatible with RN 0.57?
fyi the example project seems to work with 0.57.2 and 0.57.3 (I didn't try 0.57.1 - but note 0.57.3 depends on an alpha version of react)
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
If you believe the issue is still relevant, please test on the latest Detox and report back.
Thank you for your contributions.
Does detox work with Android ?
This is an old discussion and I think is out of date. Closing.
Most helpful comment
It's actually out since React Native 44, and getting it to 56 is being worked on currently.
The purpose of this thread is to discuss how this can be integrated with RN itself, so it will be supported on every version, regardless of internal changes in private RN APIs.