Detox: Detox doesn't work with React-Native 0.59 + React-Navigation

Describe the bug After updating our project to React-Native 0.59, I’m facing issues running Detox. The build works correctly but the application crashes as you open it with Detox.

TypeError: param is not an Object. (evaluating ''__isNative' in param')

It looks like it might be an issue by be correlated to react-navigation / react-native-gesture-handler. I use react-navigation 3.3.2

The application runs fine without Detox. As Detox adds this cursor effect to know where it taps, I think it might be the reason why it breaks only when the app runs with Detox.

I’ve created a project on my github that reproduces the bug:

https://github.com/alexmngn/DetoxBug

Screenshots

Screenshot 2019-03-14 at 09 43 38

Environment (please complete the following information):

  • Detox: 11.0.0
  • React Native: 0.59.1
  • React Navigation: 3.3.2
  • Node: 11.10.0
  • Device: iOS Simulator
  • Xcode: 10
  • iOS: 12.1
  • macOS: 10.14.3

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 7
  • Comments: 28 (12 by maintainers)

Commits related to this issue

Most upvoted comments

OK, modifying this check:

return (
   param !== undefined &&
   typeof param !== 'function' &&
   (typeof param !== 'object || !('__isNative' in param)) &&
   name !== 'onHandlerStateChange' &&
   name !== 'onGestureEvent'
);

into:

function isObject(obj) {
  return obj === Object(obj);
}

return (
    param !== undefined &&
    typeof param !== 'function' &&
    (!isObject(param) || !('__isNative' in param)) &&
    name !== 'onHandlerStateChange' &&
    name !== 'onGestureEvent'
  );

Solves this issue, because Detox is passing something that is a false positive or a false negative and it effectively breaks this check. Still can’t actually figure out what is Detox putting in there exactly, except this is a Gesture:

2019-03-15 17:43:18.530 [info][tid:com.facebook.react.JavaScript] ‘filterConfig -> value:’, null, 'key: ', ‘onGestureEvent’

And since it is passing null, all breaks.

Guys, when investigating #1234, we found that in RN59, If Detox is attached, RN thinks its in testing mode and disables some functionality. I wonder if that is not a cause of some of the issues here. I’ll release 12.1 soon with the fix for #1234. Please test if it helps with other issues discussed here.

@brentvatne good call. I’ve updated the repo https://github.com/zibs/mvce-detox-gesture-handler to use only a PanGestureHandler, and commented out all of the react-navigation code, and am getting the same result after running detox test (it works fine if built normally still). So it looks like it’s isolated between Detox and rn-gesture-handler. Something still to do with onGestureEvent={this._onGestureEvent} being null I assume.

Hi @LeoNatan this a big blocker , if we are trying the new changes then navigation stops working and if we wont then there is an error as mentioned in trail. It is very important to upgrade now on RN 59 as from August 1, 2019 Google Play will not accept apps with 32 bit only .so files. So from 59 64 bit support is added . Please can we really take care of this it will be blocker for detox growth even.

@ddzirt I have tried your changes, it looks like it doesn’t throw that error anymore, though react-navigation doesn’t seem to work at all. Not sure if it’s related though. Tapping on a button to navigate to a screen (in a stack navigator) doesn’t do anything.

Let’s close it. If something comes up that Detox doesn’t do correctly, please open a new issue. Thanks

@zibs So, I took your project and tested my solution on it:

Screen Shot 2019-03-19 at 10 09 13 Screen Shot 2019-03-19 at 10 09 15 Screen Shot 2019-03-19 at 10 09 23 Screen Shot 2019-03-19 at 10 09 45

It works. If you wish to try it yourself I can push this.