Skip to content
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 hanging on before_all hook #155

Closed
vspedr opened this issue Jun 7, 2017 · 71 comments
Closed

Tests hanging on before_all hook #155

vspedr opened this issue Jun 7, 2017 · 71 comments

Comments

@vspedr
Copy link

vspedr commented Jun 7, 2017

When I run detox test --configuration ios.sim.release --loglevel verbose --cleanup, the app is successfully installed and launched, but it won't proceed to run my test cases because it's stuck on the before() function in init.js.
I tried running the sample project but I couldn't reproduce the issue :/ any ideas?

...
detox info 5: Launching com.myapp.myapp... 
detox info 5: com.myapp.myapp launched 
detox verb ws send: {"type":"isReady","params":{},"messageId":1}
  1) "before all" hook
  0 passing (2m)
  1 failing
  1)  "before all" hook:
     Error: Timeout of 120000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves.

init.js:

require('babel-polyfill');
const detox = require('detox');
const config = require('../package.json').detox;

before(async () => {
  await detox.init(config); // it hangs here :(
});

after(async () => {
  await detox.cleanup();
});

configuration in package.json:

  "detox": {
    "specs": "e2e",
    "configurations": {
      "ios.sim.release": {
        "binaryPath": "ios/build/Build/Products/Release-iphonesimulator/myapp.app",
        "build": "export RCT_NO_LAUNCH_PACKAGER=true && xcodebuild -project ios/myapp.xcodeproj -scheme myapp -configuration Release -sdk iphonesimulator -derivedDataPath ios/build",
        "type": "ios.simulator",
        "name": "iPhone 5"
      },
      "ios.sim.debug": {
        "binaryPath": "ios/build/Build/Products/Debug-iphonesimulator/myapp.app",
        "build": "xcodebuild -project ios/myapp.xcodeproj -scheme myapp -configuration Debug -sdk iphonesimulator -derivedDataPath ios/build",
        "type": "ios.simulator",
        "name": "iPhone 5"
      }
    }
  }
@rotemmiz
Copy link
Member

rotemmiz commented Jun 7, 2017

Looks like your configuration is valid.
Mocha default reporter is pretty bad at reporting the exception when it happens inside before of the init file.

It looks like the device doesn't return a ready message after it launches the app.
Can you provide simulator log ? you can print it while running the tests: tail -1 -f ~/Library/Logs/CoreSimulator/{sim-udid}/system.log

What version of detox do you use ?
What version of node ?

@vspedr
Copy link
Author

vspedr commented Jun 7, 2017

I'm running node version 8.0.0, detox version 5.0.12.
Here's the simulator log from before running detox test until it exits with timeout:

https://pastebin.com/g48LsN3J

@rotemmiz
Copy link
Member

rotemmiz commented Jun 8, 2017

Nothing seems to be wrong with your simulator log. Does the app crash ? did you try running in with ios.sim.debug ?
Please try running the same scenario with detox@5.1.0.

@vspedr
Copy link
Author

vspedr commented Jun 9, 2017

Nope, it does not crash, it just remains idle in foreground. Sure, I'll try again soon and post my results. Thanks :)

@vspedr
Copy link
Author

vspedr commented Jun 9, 2017

Ok, so I gave detox@5.1.0 a try and the same thing happened: builds, installs and lanches correctly, but hangs before running test cases, both in release and debug configurations.

users-MacBook-Pro:myapp user$ detox test --configuration ios.sim.debug --loglevel verbose --cleanup
node_modules/.bin/mocha e2e --opts e2e/mocha.opts --configuration ios.sim.debug --loglevel verbose --cleanup


detox info 10:32:07: server listening on localhost:55957...
detox verb ws onOpen [object Object]
detox verb ws send: {"type":"login","params":{"sessionId":"ca6e4e16-8ace-21a6-8f13-00ebf8492315","role":"tester"},"messageId":0}
detox verb 1: fbsimctl --json "iPhone 5" --first 1 --simulators list
detox info 1: Listing devices...
detox verb 2: fbsimctl --json --state=shutdown --state=shutting-down 546896F6-37A1-4552-B4F2-178D49363585 boot
detox info 2: trying to boot device...
detox info 2: device 546896F6-37A1-4552-B4F2-178D49363585 booted
detox verb 3: fbsimctl --json 546896F6-37A1-4552-B4F2-178D49363585 uninstall com.myapp.debug
detox info 3: Uninstalling com.myapp.debug...
detox info 3: com.myapp.debug uninstalled
detox verb 4: fbsimctl --json 546896F6-37A1-4552-B4F2-178D49363585 install /Users/user/Projects/myapp/ios/build/Build/Products/Debug-iphonesimulator/myapp.app
detox info 4: Installing /Users/user/Projects/myapp/ios/build/Build/Products/Debug-iphonesimulator/myapp.app...
detox info 4: /Users/user/Projects/myapp/ios/build/Build/Products/Debug-iphonesimulator/myapp.app installed
detox verb 5: export FBSIMCTL_CHILD_DYLD_INSERT_LIBRARIES="/Users/user/Projects/myapp/node_modules/detox/Detox.framework/Detox" && fbsimctl --json 546896F6-37A1-4552-B4F2-178D49363585 launch --stderr com.myapp.debug -detoxServer ws://localhost:55957 -detoxSessionId ca6e4e16-8ace-21a6-8f13-00ebf8492315
detox info 5: Launching com.myapp.debug...
detox info 5: com.myapp.debug launched
detox verb ws send: {"type":"isReady","params":{},"messageId":-1000}
  1) "before all" hook

  0 passing (2m)
  1 failing

  1)  "before all" hook:
     Error: Timeout of 120000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves.




child_process.js:611
    throw err;
    ^

Error: Command failed: node_modules/.bin/mocha e2e --opts e2e/mocha.opts --configuration ios.sim.debug --loglevel verbose --cleanup
    at checkExecSyncError (child_process.js:568:13)
    at Object.execSync (child_process.js:608:13)
    at Object.<anonymous> (/Users/user/Projects/myapp/node_modules/detox/local-cli/detox-test.js:43:4)
    at Module._compile (module.js:569:30)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:503:32)
    at tryModuleLoad (module.js:466:12)
    at Function.Module._load (module.js:458:3)
    at Function.Module.runMain (module.js:605:10)
    at startup (bootstrap_node.js:158:16)

Simulator logs:
https://pastebin.com/z0BivPcy

@minhtc
Copy link

minhtc commented Jun 10, 2017

same @vspedr

@vspedr
Copy link
Author

vspedr commented Jun 12, 2017

By the way, I'm using react native version 0.44.2

@eeynard
Copy link

eeynard commented Jun 29, 2017

Hi ! Same problem for me.
detox: 5.2.0
react-native: 0.44.3
mocha: 3.4.2

@rotemmiz
Copy link
Member

@vspedr do you see the app loading on simulator screen ?

Can't get a full understanding of what's happening yet, but this is what I understand form the logs:

  1. The Detox verbose log states that the simulator never reported that it is ready (it should report that when the app gets loaded and react native finishes parsing the bundle and loading the UI to screen)
  2. The system.log shows some sort of issue with the websocket connection to the packager

@vspedr
Copy link
Author

vspedr commented Jun 29, 2017

Hello @rotemmiz,
Yes, I do see the app launching, loading and running, both in Debug and Release configs, but it only shows the main screen and stays there. Console shows detox info 5: com.myapp.myapp launched then gets stuck until it times out.

Is there any other info I can get to help you?

EDIT: I just noticed 5.2.0 has been released, will give it a try ASAP

@mCodex
Copy link

mCodex commented Jun 29, 2017

Hello guys, I work with @vspedr and today I built detox (5.2.0) from scratch in our project and unfortunately the error persists. I used node 7.6.0, 7.8.0 and 8.1.3 with xcode 8.3.3 (Simulators: iPhone 5, iPhone 7, iPhone 7 Plus) using react-native 0.44.2.

@rotemmiz
Copy link
Member

rotemmiz commented Jun 29, 2017

I think Detox tries to throw an error inside mocha's beforeAll hook , but for some reason mocha catches all errors thrown inside beforeAll. As a workaround, try surrounding detox.init()
with a try/catch clause, and print the exception. What does it say ?

@mCodex
Copy link

mCodex commented Jun 29, 2017

Hello @rotemmiz , thank you for your quick response, but, unfortunately, the code doesn't reach the exception 😢

@rotemmiz
Copy link
Member

Hmm.. :(

Let's try to see if the device even tries talks back to the tester.
Try configuring a manual session: https://github.com/wix/detox/blob/master/docs/APIRef.Configuration.md#server-configuration

and then run detox run-server in a different window before running detox test
This will start the detox server, and will log any connection to it. You should see a login message from testee (the device) when the app launches.

@mCodex
Copy link

mCodex commented Jun 30, 2017

Hello @rotemmiz, first of all sorry for the delay. I'd like to ask you how do I get the SessionId for my app? 🤔

@rotemmiz
Copy link
Member

It is whatever string you want there

@mCodex
Copy link

mCodex commented Jun 30, 2017

Thank you @rotemmiz, this is what I get:

detox-server info 07:46:22: server listening on localhost:8099...
detox-server wss 07:47:53: role=tester login (sessionId=123)
detox-server wss 07:48:28: role=tester action=isReady (sessionId=123)
detox-server wss 07:48:28: role=testee not connected, cannot fw action (sessionId=123)
detox-server wss 07:49:53: role=tester disconnect (sessionId=123)
detox-server wss 08:01:38: role=tester login (sessionId=abcdef)
detox-server wss 08:01:45: role=tester action=isReady (sessionId=abcdef)
detox-server wss 08:01:45: role=testee not connected, cannot fw action (sessionId=abcdef)

@rotemmiz
Copy link
Member

Yep, the device never connects to the websocket server.
If you want , we can debug the device code and see why it doesn't connect to the server.
Here sre the basic steps of setting a debuggeble env with Xcode.
https://github.com/wix/detox/blob/master/docs/Guide.DebuggingInXcode.md

@adamski
Copy link

adamski commented Jul 2, 2017

I seem to be having the same issue. I'll dig a little and try and provide some debug info

@adamski
Copy link

adamski commented Jul 2, 2017

Trying to run detox run-server I get:

/bin/sh: node_modules/detox/node_modules/.bin/detox-server: No such file or directory
child_process.js:524
    throw err;
    ^

Error: Command failed: node_modules/detox/node_modules/.bin/detox-server
    at checkExecSyncError (child_process.js:481:13)
    at Object.execSync (child_process.js:521:13)
    at Object.<anonymous> (/Users/adamelemental/dev/Phona/sayit/node_modules/detox/local-cli/detox-run-server.js:13:6)
    at Module._compile (module.js:571:32)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:488:32)
    at tryModuleLoad (module.js:447:12)
    at Function.Module._load (module.js:439:3)
    at Module.runMain (module.js:605:10)
    at run (bootstrap_node.js:427:7)

@rotemmiz
Copy link
Member

rotemmiz commented Jul 2, 2017

@adamski, does 'detox test' work? Did you 'npm install' ? Are you running from your project's root dir?

@adamski
Copy link

adamski commented Jul 2, 2017

@rotemmiz yes detox test works (before the hang). Yes running from project root dir. And I did another npm install just to make sure. Same error message.

@adamski
Copy link

adamski commented Jul 2, 2017

@rotemmiz I noticed the detox-server is a separate node module, i.e. at node_modules/detox-server, so the path node_modules/detox/node_modules/.bin/detox-server does not make sense - the only modules within detox are gauge and npmlog.

@adamski
Copy link

adamski commented Jul 2, 2017

@rotemmiz got it working with node node_modules/detox-server/lib/cli.js

Similar to @mCodex I get the following output from the detox-server:

detox-server info 14:26:44: server listening on localhost:8099...
detox-server wss 14:29:55: role=tester login (sessionId=test)
detox-server wss 14:29:55: role=tester action=isReady (sessionId=test)
detox-server wss 14:29:55: role=testee not connected, cannot fw action (sessionId=test)

Xcode output shows one of these around every second:

2017-07-02 14:33:00.750040+0100 MyApp[71467:2780079] [] nw_connection_get_connected_socket_block_invoke 128 Connection has no connected handler

I realise this is a known issue for iOS 10, just wondering if there Is there some Plist item missing to allow web socket connections that might preventing the connection?

@adamski
Copy link

adamski commented Jul 2, 2017

@rotemmiz Not sure how to proceed, I've followed the steps at https://github.com/wix/detox/blob/master/docs/Guide.DebuggingInXcode.md - can't see anything obvious that might relate to the 'device code' you mention.

@rotemmiz
Copy link
Member

rotemmiz commented Jul 2, 2017

@adamski
Copy link

adamski commented Jul 2, 2017

OK thanks, just not sure how to get to the DetoxManager.m file? I can only see the header drilling into the framework in Xcode.

@rotemmiz
Copy link
Member

rotemmiz commented Jul 2, 2017

If you followed the Xcode debugging steps you should have the framework linked to your project:
https://github.com/wix/detox/blob/master/docs/Guide.DebuggingInXcode.md#step-1-add-detox-framework-to-your-project

@jonathancopperstone
Copy link

@fighterpoul for us iOS noobs, where did you remove the ARCHS=i386 flag from?

@jonathancopperstone
Copy link

This issue seems to have been introduced with the 5.6.0 release. Reverting back to 5.5.1 sorts the issue of the simulator hanging and not calling back.

@rotemmiz
Copy link
Member

rotemmiz commented Sep 7, 2017

What version of Xcode are you using?

@LeoNatan
Copy link
Contributor

LeoNatan commented Sep 7, 2017

@fighterpoul @adamski Guys, why are you building with the ARCHS=i386 in the first place?

Detox is 64-bit only—only x86-64 and arm64 slices are provided. i386 is 32-bit architecture and I would like to understand why you are building in 32-bit only. This is not something you should do—standard architectures in Xcode normally include 32-bit and 64-bit.

@jonathancopperstone
Copy link

@rotemmiz 8.2.1

I've checked out the repo and am currently taking a look. It gets stuck in ./detox/src/client/Client.js inside the sendAction fn on this line:

const response = await this.ws.send(action, messageId)

It never resolves. I've noticed the AsyncWebSocket has changed, and doesn't resolve if there is no pendingPromise. Not sure if that might have something to do with it. Still trying to make sense of how Detox works

@jonathancopperstone
Copy link

I'm out of ideas @rotemmiz. I'll try and find some time to continue looking into this if noone else has a chance, however I doubt I'll find time until early next week.

In the meantime I'll carry on with 5.5.1, launch date is looming large!

@fighterpoul
Copy link

fighterpoul commented Sep 9, 2017

@LeoNatan as I mentioned before - I don't remember why I was needed to use the flag (probably I had some build issues). I do remember that after reinstalling all tools used by Detox and making sure that all are installed according to documentation and removing the flag everything started to work fine.
BTW I was trying use Detox with native application without any RN code.

@johnnycopperstone in a config file you have build command, here's the doc: link

@LeoNatan
Copy link
Contributor

LeoNatan commented Sep 9, 2017

That flag is not related to RN. It tells Xcode to build a 32-bit application. We dropped 32-bit support from Detox a while ago because it wasn’t really needed—since a few years Apple requires 64-bit binary support. So there is no reason to build 32-bit only builds, unless specifically debugging an issue related to 32-bit; in such cases, Detox is not supported.

@proshoumma
Copy link

I'm having the same issue. Not happening on a release build, but stuck on the debug build.

@proshoumma
Copy link

I have got it fixed by doing a re-install of all node modules and a detox build.

@apolishch
Copy link

I am hitting this issue, but only in CircleCI. Running a clean rebuild with cache cleaned, does not fix it.

Locally, everything is fine.

@vspedr
Copy link
Author

vspedr commented Sep 11, 2017

Hey @LeoNatan thanks for your explanation about 32-bit binaries, it may be the cause of the issue for me as I mentioned in this issue: #153
I will update that issue so people don't try to 'solve' things the wrong way like I did 😆

@abrel
Copy link

abrel commented Sep 11, 2017

Hi,
I have got the same issue.
In my case it seems to come from a crash within EarlGrey Framework

see

NSUncaughtExceptionHandler is 'grey_uncaughtExceptionHandler' in '/Users/alexandrebrel/Desktop/Karma/karmaMobile/node_modules/detox/Detox.framework/Frameworks/EarlGrey.framework/EarlGrey'

react native: 0.47.2
detox: 5.6.2

2017-09-12 00:09:20.040 karmaMobile[57587:1695265] ☣️ DETOX:: Removing observed timer 1
2017-09-12 00:09:20.085 karmaMobile[57587:1695246] ☣️ Adding idling resource for queue: <OS_dispatch_queue: com.facebook.react.ImageLoaderQueue[0x6080002ee080]>
2017-09-12 00:09:20.086 karmaMobile[57587:1695246] ☣️ Adding idling resource for queue: <OS_dispatch_queue: com.facebook.react.LocalAssetImageLoaderQueue[0x6000002ecc00]>
2017-09-12 00:09:20.087 karmaMobile[57587:1695259] ☣️ Adding idling resource for queue: <OS_dispatch_queue: com.facebook.react.NetworkingQueue[0x6080002ee100]>
2017-09-12 00:09:20.087 karmaMobile[57587:1695259] ☣️ Adding idling resource for queue: <OS_dispatch_queue: com.facebook.react.ImageStoreManagerQueue[0x6000002ed000]>
2017-09-12 00:09:20.087 karmaMobile[57587:1695259] ☣️ Adding idling resource for queue: <OS_dispatch_queue: com.facebook.react.FileRequestHandlerQueue[0x6000002ed280]>
2017-09-12 00:09:20.088 karmaMobile[57587:1695259] ☣️ Adding idling resource for queue: <OS_dispatch_queue: com.facebook.react.DataRequestHandlerQueue[0x6080002ee300]>
2017-09-12 00:09:20.088 karmaMobile[57587:1695259] ☣️ Adding idling resource for queue: <OS_dispatch_queue: com.facebook.react.HTTPRequestHandlerQueue[0x6000002e5c00]>
2017-09-12 00:09:20.154 karmaMobile[57587:1695252] ☣️ Adding idling resource for queue: <OS_dispatch_queue: com.facebook.react.GIFImageDecoderQueue[0x6080002ee180]>
2017-09-12 00:09:20.875 karmaMobile[57587:1695246] [Crashlytics:Crash] Warning: NSUncaughtExceptionHandler is 'grey_uncaughtExceptionHandler' in '/Users/alexandrebrel/Desktop/Karma/karmaMobile/node_modules/detox/Detox.framework/Frameworks/EarlGrey.framework/EarlGrey'
2017-09-12 00:09:21.800 karmaMobile[57587:1695265] ☣️ DETOX:: Ignoring timer: 26 failure reason: "duration>1.5"
2017-09-12 00:09:23.814 karmaMobile[57587:1695265] ☣️ DETOX:: Ignoring timer: 27 failure reason: "duration>1.5"
2017-09-12 00:09:25.823 karmaMobile[57587:1695265] ☣️ DETOX:: Ignoring timer: 28 failure reason: "duration>1.5"
2017-09-12 00:09:27.834 karmaMobile[57587:1695265] ☣️ DETOX:: Ignoring timer: 29 failure reason: "duration>1.5"
2017-09-12 00:09:28.329 karmaMobile[57587:1695265] ☣️ DETOX:: Ignoring timer: 30 failure reason: "duration>1.5"
2017-09-12 00:09:29.843 karmaMobile[57587:1695265] ☣️ DETOX:: Ignoring timer: 31 failure

@tyronet-sportsbet
Copy link
Contributor

An update on @timsawtell-sportsbet's issue: we are running Detox in a hybrid React Native / Native app. Since no React Native components render on the home screen of our app, the RCTContentDidAppearNotification notification is never fired by React Native. As a result, Detox gets stuck waiting for React Native to "load".

There's a fundamental assumption in Detox that if your app has React Native symbols linked into it, then it will be a purely React Native app and you're guaranteed to have RCTContentDidAppearNotification fire pretty soon after the app launches, which isn't necessarily the case in a hybrid app that only uses React Native for a subsection of user journeys.

The solution in our case was simple, we manually fire an RCTContentDidAppearNotification after we've finished downloading our jsbundle:

[NSNotificationCenter.defaultCenter postNotificationName: @"RCTContentDidAppearNotification" object: nil];

@proshoumma
Copy link

I faced it again today. For me the issue occurs after I installed react-native-repackager and perform the patching process. After that, when I ran detox test, it stuck on the initial screen of my app. Then I perform a detox build, and it works!

@cris-santos
Copy link

I'm getting a similar error when I run it on Travis CI. Locally works fine

Node v8.4.0

yarn list v0.24.6
├─ detox@5.6.2
├─ mocha@3.5.2
└─ react-native@0.48.2
The command "detox build --configuration ios.sim.debug" exited with 0.
125.32s$ detox test --configuration ios.sim.debug --cleanup
node_modules/.bin/mocha ./__e2e__ --opts ./__e2e__/mocha.opts --configuration ios.sim.debug  --cleanup   
detox-server info 20:30:13: server listening on localhost:52073...
detox info 1: Listing devices... 
detox info 3: Launching device 15E2107D-EAD2-4E1F-8BC3-59E58E750FB1... 
detox info 4: Waiting for device 15E2107D-EAD2-4E1F-8BC3-59E58E750FB1 to boot... 
detox info 4: Device 15E2107D-EAD2-4E1F-8BC3-59E58E750FB1 booted 
detox info 5: Uninstalling co.torch.Torch... 
detox info 6: Installing /Users/travis/build/MyProject/ios/build/Build/Products/Debug-iphonesimulator/MyProject.app... 
detox info 6: Installing /Users/travis/build/MyProject/ios/build/Build/Products/Debug-iphonesimulator/MyProject.app... 
detox info 6: /Users/travis/build/MyProject/ios/build/Build/Products/Debug-iphonesimulator/MyProject.app installed 
detox info 7: Terminating co.MyProject... 
detox info 7: co.MyProject terminated 
detox info 8: Launching co.MyProject... 
detox info 8: co.MyProject launched. The stdout and stderr logs were recreated, you can watch them with:
        tail -F $HOME/Library/Developer/CoreSimulator/Devices/15E2107D-EAD2-4E1F-8BC3-59E58E750FB1/data/tmp/detox.last_launch_app_log.{out,err} 
  1) "before all" hook
  0 passing (2m)
  1 failing
  1)  "before all" hook:
     Error: Timeout of 120000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves.
  
child_process.js:634
    throw err;
    ^
Error: Command failed: node_modules/.bin/mocha ./__e2e__ --opts ./__e2e__/mocha.opts --configuration ios.sim.debug  --cleanup   
    at checkExecSyncError (child_process.js:591:13)
    at Object.execSync (child_process.js:631:13)
    at Object.<anonymous> (/Users/travis/build/MyProject/node_modules/detox/local-cli/detox-test.js:46:4)
    at Module._compile (module.js:573:30)
    at Object.Module._extensions..js (module.js:584:10)
    at Module.load (module.js:507:32)
    at tryModuleLoad (module.js:470:12)
    at Function.Module._load (module.js:462:3)
    at Function.Module.runMain (module.js:609:10)
    at startup (bootstrap_node.js:158:16)
The command "detox test --configuration ios.sim.debug --cleanup" exited with 1.
Done. Your build exited with 1.
/Users/travis/.travis/job_stages: line 166: shell_session_update: command not found

Already tried:

  • Node 7.4
  • Detox 5.6.0 and 5.5.1
  • Build Release instead of Debug

Any thoughts?

@jaredramirez
Copy link

Hey, I'm having the same issue.

Version:

Node: 7.10.0
Detox: 5.7.0 (and 5.6.0)
Release: Debug and Release

My config in package.json:

"detox": {
    "specs": "e2e",
    "configurations": {
      "ios.sim.debug": {
        "binaryPath": "ios/build/Build/Products/Debug-iphonesimulator/HaulerMobile.app",
        "build": "xcodebuild -project ios/HaulerMobile.xcodeproj -scheme HaulerMobile -configuration Debug -sdk iphonesimulator -derivedDataPath ios/build",
        "type": "ios.simulator",
        "name": "iPhone 7"
      }
    }
  },

I run detox test after building with react-native run-ios. It starts to run, and the app immediately crashes.

For me, it also hangs in init.js

before(async () => {
  console.log('before');
  await detox.init(config); // HERE
  console.log('after');
});

And the result in the terminal:

$ detox test --loglevel verbose
node_modules/.bin/mocha e2e --opts e2e/mocha.opts  --loglevel verbose


before
detox info 13:32:23: server listening on localhost:51955...
detox verb ws onOpen [object Object]
detox verb ws send: {"type":"login","params":{"sessionId":"46f28899-07f2-c244-f894-28a85435648a","role":"tester"},"messageId":0}
detox verb ws onMessage: {"type":"loginSuccess","params":{"sessionId":"46f28899-07f2-c244-f894-28a85435648a","role":"tester"},"messageId":0}
detox verb ws
detox verb 1: fbsimctl --json "iPhone 7" --first 1 --simulators list
detox info 1: Listing devices...
detox verb 2: fbsimctl --json F0C11864-91E1-4323-AD01-BF9867279CEB list
detox info Device F0C11864-91E1-4323-AD01-BF9867279CEB is already booted
detox verb 3: fbsimctl --json F0C11864-91E1-4323-AD01-BF9867279CEB uninstall org.reactjs.native.example.HaulerMobile
detox info 3: Uninstalling org.reactjs.native.example.HaulerMobile...
detox info 3: org.reactjs.native.example.HaulerMobile uninstalled
detox verb 4: fbsimctl --json F0C11864-91E1-4323-AD01-BF9867279CEB install /Users/jaredramirez/dev/src/github.com/replenysh/Hauler-Mobile/ios/build/Build/Products/Debug-iphonesimulator/HaulerMobile.app
detox info 4: Installing /Users/jaredramirez/dev/src/github.com/replenysh/Hauler-Mobile/ios/build/Build/Products/Debug-iphonesimulator/HaulerMobile.app...
detox info 4: /Users/jaredramirez/dev/src/github.com/replenysh/Hauler-Mobile/ios/build/Build/Products/Debug-iphonesimulator/HaulerMobile.app installed
detox verb 5: /usr/bin/xcrun simctl terminate F0C11864-91E1-4323-AD01-BF9867279CEB org.reactjs.native.example.HaulerMobile
detox info 5: Terminating org.reactjs.native.example.HaulerMobile...
detox info 5: org.reactjs.native.example.HaulerMobile terminated
detox verb 6: /bin/cat /dev/null >$HOME/Library/Developer/CoreSimulator/Devices/F0C11864-91E1-4323-AD01-BF9867279CEB/data/tmp/detox.last_launch_app_log.out 2>$HOME/Library/Developer/CoreSimulator/Devices/F0C11864-91E1-4323-AD01-BF9867279CEB/data/tmp/detox.last_launch_app_log.err && SIMCTL_CHILD_DYLD_INSERT_LIBRARIES="/Users/jaredramirez/dev/src/github.com/replenysh/Hauler-Mobile/node_modules/detox/Detox.framework/Detox" /usr/bin/xcrun simctl launch --stdout=/tmp/detox.last_launch_app_log.out --stderr=/tmp/detox.last_launch_app_log.err F0C11864-91E1-4323-AD01-BF9867279CEB org.reactjs.native.example.HaulerMobile --args -detoxServer ws://localhost:51955 -detoxSessionId 46f28899-07f2-c244-f894-28a85435648a
detox info 6: Launching org.reactjs.native.example.HaulerMobile...
detox info 6: org.reactjs.native.example.HaulerMobile launched. The stdout and stderr logs were recreated, you can watch them with:
        tail -F $HOME/Library/Developer/CoreSimulator/Devices/F0C11864-91E1-4323-AD01-BF9867279CEB/data/tmp/detox.last_launch_app_log.{out,err}
detox verb ws send: {"type":"isReady","params":{},"messageId":-1000}
  1) "before all" hook

  0 passing (2m)
  1 failing

  1)  "before all" hook:
     Error: Timeout of 120000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves.




child_process.js:524
    throw err;
    ^

Error: Command failed: node_modules/.bin/mocha e2e --opts e2e/mocha.opts  --loglevel verbose
    at checkExecSyncError (child_process.js:481:13)
    at Object.execSync (child_process.js:521:13)
    at Object.<anonymous> (/Users/jaredramirez/dev/src/github.com/replenysh/Hauler-Mobile/node_modules/detox/local-cli/detox-test.js:46:4)
    at Module._compile (module.js:571:32)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:488:32)
    at tryModuleLoad (module.js:447:12)
    at Function.Module._load (module.js:439:3)
    at Module.runMain (module.js:605:10)
    at run (bootstrap_node.js:427:7)

The output from my system log is

Sep 21 13:32:23 jared-macbook CoreSimulatorBridge[32672]: Pasteboard change listener callback port <NSMachPort: 0x7faae9726400> registered
Sep 21 13:32:24 jared-macbook CoreSimulatorBridge[32672]: Pasteboard change listener callback port <NSMachPort: 0x7faae941bea0> registered
Sep 21 13:32:24 jared-macbook CoreSimulatorBridge[32672]: Pasteboard change listener callback port <NSMachPort: 0x7faae9725c20> registered
Sep 21 13:32:24 jared-macbook installd[32661]: 0x700006ae2000 -[MIClientConnection uninstallIdentifiers:withOptions:completion:]: Uninstall requested by lsd (pid 32681) for identifier org.reactjs.native.example.HaulerMobile with options: {
	    SimulatorRootPath = "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk";
	    SimulatorUserPath = "/Users/jaredramirez/Library/Developer/CoreSimulator/Devices/F0C11864-91E1-4323-AD01-BF9867279CEB/data";
	}
Sep 21 13:32:24 jared-macbook diagnosticd[32678]: unsupported XPC object: OS_xpc_dictionary
Sep 21 13:32:24 jared-macbook installd[32661]: 0x700006ae2000 -[MIUninstaller _uninstallBundleWithIdentifier:error:]: Uninstalling identifier org.reactjs.native.example.HaulerMobile
Sep 21 13:32:24 jared-macbook installd[32661]: 0x700006ae2000 -[MIKeychainAccessGroupTracker _onQueue_removeReferencesForBundle:error:]: Removing reference in org.reactjs.native.example.HaulerMobile for Q233EUCZ3X.org.reactjs.native.example.HaulerMobile
Sep 21 13:32:24 jared-macbook installd[32661]: 0x700006ae2000 -[MIKeychainAccessGroupTracker _removeGroupsWithError:error:]: Removing keychain access groups: (
	    "Q233EUCZ3X.org.reactjs.native.example.HaulerMobile"
	)
Sep 21 13:32:24 jared-macbook installd[32661]: 0x700006ae2000 -[MIUninstallNotifier performRemovalWithCompletionBlock:]: Destroying container with identifier org.reactjs.native.example.HaulerMobile at /Users/jaredramirez/Library/Developer/CoreSimulator/Devices/F0C11864-91E1-4323-AD01-BF9867279CEB/data/Containers/Bundle/Application/3DF0A425-9BF4-4AA9-8D05-FB9672FE5742
Sep 21 13:32:24 jared-macbook installd[32661]: 0x700006ae2000 -[MIUninstallNotifier performRemovalWithCompletionBlock:]: Destroying container with identifier org.reactjs.native.example.HaulerMobile at /Users/jaredramirez/Library/Developer/CoreSimulator/Devices/F0C11864-91E1-4323-AD01-BF9867279CEB/data/Containers/Data/Application/ACC0FE31-6D6F-4946-850C-843CD6D00E10
Sep 21 13:32:24 jared-macbook diagnosticd[32678]: unsupported XPC object: OS_xpc_dictionary
Sep 21 13:32:24 --- last message repeated 3 times ---
Sep 21 13:32:24 jared-macbook SpringBoard[32666]: [Common] could not find icon for representation -> org.reactjs.native.example.HaulerMobile
Sep 21 13:32:24 jared-macbook apsd[32693]: 2017-09-21 13:32:24 -0500 apsd[32693]: SecItemDelete() failed: -25300 - setTokenForDomain
Sep 21 13:32:24 jared-macbook diagnosticd[32678]: unsupported XPC object: OS_xpc_dictionary
Sep 21 13:32:24 jared-macbook apsd[32693]: 2017-09-21 13:32:24 -0500 apsd[32693]: SecItemDelete() failed: -25300 - setTokenForDomain
Sep 21 13:32:24 jared-macbook diagnosticd[32678]: unsupported XPC object: OS_xpc_dictionary
Sep 21 13:32:24 --- last message repeated 1 time ---
Sep 21 13:32:24 jared-macbook videosubscriptionsd[33167]: Entering main() for videosubscriptionsd.
Sep 21 13:32:24 jared-macbook diagnosticd[32678]: unsupported XPC object: OS_xpc_dictionary
Sep 21 13:32:24 jared-macbook videosubscriptionsd[33167]: Unable to find framework using path: /System/Library/Frameworks/VideoSubscriberAccount.framework
Sep 21 13:32:24 jared-macbook com.apple.CoreSimulator.SimDevice.F0C11864-91E1-4323-AD01-BF9867279CEB.launchd_sim[32648] (com.apple.videosubscriptionsd[33167]): Service exited with abnormal code: 1
Sep 21 13:32:24 jared-macbook diagnosticd[32678]: unsupported XPC object: OS_xpc_dictionary
Sep 21 13:32:24 jared-macbook CoreSimulatorBridge[32672]: Pasteboard change listener callback port <NSMachPort: 0x7faae941e870> registered
Sep 21 13:32:25 jared-macbook CoreSimulatorBridge[32672]: Requesting installation of file:///Users/jaredramirez/dev/src/github.com/replenysh/Hauler-Mobile/ios/build/Build/Products/Debug-iphonesimulator/HaulerMobile.app/ with options: {
	    CFBundleIdentifier = "org.reactjs.native.example.HaulerMobile";
	    PackageType = Developer;
	    SimulatorRootPath = "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk";
	    SimulatorUserPath = "/Users/jaredramirez/Library/Developer/CoreSimulator/Devices/F0C11864-91E1-4323-AD01-BF9867279CEB/data";
	}
Sep 21 13:32:25 jared-macbook installd[32661]: 0x700006b65000 -[MIClientConnection _doInstallationForURL:withOptions:completion:]: Install of "/Users/jaredramirez/dev/src/github.com/replenysh/Hauler-Mobile/ios/build/Build/Products/Debug-iphonesimulator/HaulerMobile.app" type Developer (LSInstallType = (null)) requested by lsd (pid 32681)
Sep 21 13:32:25 jared-macbook installd[32661]: 0x700006b65000 -[MIInstaller _extractPackageWithError:]: Did not construct delta; doing full copy for installation.
Sep 21 13:32:25 jared-macbook installd[32661]: 0x700006b65000 -[MIInstaller performInstallationWithError:]: Installing <MIInstallableBundle ID=org.reactjs.native.example.HaulerMobile; Version=1, ShortVersion=1.0>
Sep 21 13:32:25 jared-macbook installd[32661]: 0x700006b65000 -[MIContainer makeContainerLiveReplacingContainer:reason:withError:]: Made container live for org.reactjs.native.example.HaulerMobile at /Users/jaredramirez/Library/Developer/CoreSimulator/Devices/F0C11864-91E1-4323-AD01-BF9867279CEB/data/Containers/Data/Application/642363F7-6520-4FA7-A580-5C1F3EF4BB11
Sep 21 13:32:25 jared-macbook installd[32661]: 0x700006b65000 -[MIContainer makeContainerLiveReplacingContainer:reason:withError:]: Made container live for org.reactjs.native.example.HaulerMobile at /Users/jaredramirez/Library/Developer/CoreSimulator/Devices/F0C11864-91E1-4323-AD01-BF9867279CEB/data/Containers/Bundle/Application/A15460D7-5152-460F-A41B-D25C2E92713A
Sep 21 13:32:25 jared-macbook installd[32661]: 0x700006b65000 -[MIInstaller performInstallationWithError:]: Install Successful; Staging: 0.11s; Waiting: 0.00s; Preflight/Patch: 0.00s, Verifying: 0.01s; Overall: 0.15s
Sep 21 13:32:25 jared-macbook com.apple.CoreSimulator.SimDevice.F0C11864-91E1-4323-AD01-BF9867279CEB.launchd_sim[32648] (com.apple.videosubscriptionsd): Service only ran for 1 seconds. Pushing respawn out by 9 seconds.
Sep 21 13:32:30 jared-macbook CoreSimulatorBridge[32672]: Pasteboard change listener callback port <NSMachPort: 0x7faae9607c10> registered
Sep 21 13:32:30 jared-macbook CoreSimulatorBridge[32672]: Pasteboard change listener callback port <NSMachPort: 0x7faae9417b90> registered
Sep 21 13:32:30 jared-macbook CoreSimulatorBridge[32672]: Requesting launch of org.reactjs.native.example.HaulerMobile with options: {
	    arguments =     (
	        "--args",
	        "-detoxServer",
	        "ws://localhost:51955",
	        "-detoxSessionId",
	        "46f28899-07f2-c244-f894-28a85435648a"
	    );
	    environment =     {
	        "DYLD_INSERT_LIBRARIES" = "/Users/jaredramirez/dev/src/github.com/replenysh/Hauler-Mobile/node_modules/detox/Detox.framework/Detox";
	    };
	    stderr = "/tmp/detox.last_launch_app_log.err";
	    stdout = "/tmp/detox.last_launch_app_log.out";
	}
Sep 21 13:32:30 jared-macbook CoreSimulatorBridge[32672]: Beginning launch sequence for bundle 'org.reactjs.native.example.HaulerMobile'
		retryTimeout: 120.000000 (default write com.apple.CoreSimulatorBridge LaunchRetryTimeout <value>)
		bootTimeout: 300.000000 (default write com.apple.CoreSimulatorBridge BootRetryTimeout <value>)
		bootLeeway: 120.000000 (default write com.apple.CoreSimulatorBridge BootLeeway <value>)
		Note: Use 'xcrun simctl spawn booted defaults write <domain> <key> <value>' to modify defaults in the booted Simulator device.
	Simulator booted at: 2017-09-21 18:00:11 +0000
	Current time: 2017-09-21 18:32:30 +0000
	Within boot leeway: NO
Sep 21 13:32:30 jared-macbook CoreSimulatorBridge[32672]: Launch attempt #0 for bundle 'org.reactjs.native.example.HaulerMobile', have been trying to launch for 0 seconds. Modern launch services = YES
Sep 21 13:32:30 jared-macbook CoreSimulatorBridge[32672]: Got LSBundleProxy for 'org.reactjs.native.example.HaulerMobile', sequenceNumber 260, cacheGUID 071680E1-C239-43EF-A511-91F96955DD19
Sep 21 13:32:30 jared-macbook CoreSimulatorBridge[32672]: [Common] [FBSSystemService][0x9577] Sending request to open "org.reactjs.native.example.HaulerMobile"
Sep 21 13:32:30 jared-macbook assertiond[32671]: Submitted job with label: UIKitApplication:org.reactjs.native.example.HaulerMobile[0x62ec][32671]
Sep 21 13:32:30 jared-macbook SpringBoard[32666]: [org.reactjs.native.example.HaulerMobile] Bootstrap complete with label: UIKitApplication:org.reactjs.native.example.HaulerMobile[0x62ec][32671]
Sep 21 13:32:30 jared-macbook CoreSimulatorBridge[32672]: [Common] [FBSSystemService][0x9577] Request successful: <BSProcessHandle: 0x7faae9725330; HaulerMobile:33180; valid: YES>
Sep 21 13:32:30 jared-macbook CoreSimulatorBridge[32672]: Launch successful for 'org.reactjs.native.example.HaulerMobile'
Sep 21 13:32:30 jared-macbook HaulerMobile[33180]: Crash handler setup started.
Sep 21 13:32:30 jared-macbook HaulerMobile[33180]: Crash handler setup completed.
Sep 21 13:32:30 jared-macbook HaulerMobile[33180]: Enabling accessibility for automation on Simulator.
Sep 21 13:32:30 jared-macbook HaulerMobile[33180]: assertion failed: 16G29 14E8301: libxpc.dylib + 64131 [624BAF4F-2E03-34F8-ACBA-970B04637786]: 0x7d
Sep 21 13:32:31 jared-macbook HaulerMobile[33180]: Initializing <RCTCxxBridge: 0x6000001bb040> (parent: <RCTBridge: 0x6080000a2760>, executor: (null))
Sep 21 13:32:31 jared-macbook HaulerMobile[33180]: Class RCTCxxModule was not exported. Did you forget to use RCT_EXPORT_MODULE()?
Sep 21 13:32:31 jared-macbook SpringBoard[32666]: [KeyboardArbiter] HW kbd: Failed to set (null) as keyboard focus
Sep 21 13:32:31 jared-macbook com.apple.CoreSimulator.SimDevice.F0C11864-91E1-4323-AD01-BF9867279CEB.launchd_sim[32648] (UIKitApplication:org.reactjs.native.example.HaulerMobile[0x62ec][32671][33180]): Service exited due to Abort trap: 6
Sep 21 13:32:31 jared-macbook assertiond[32671]: Deleted job with label: UIKitApplication:org.reactjs.native.example.HaulerMobile[0x62ec][32671]
Sep 21 13:32:34 jared-macbook videosubscriptionsd[33182]: Entering main() for videosubscriptionsd.
Sep 21 13:32:34 jared-macbook videosubscriptionsd[33182]: Unable to find framework using path: /System/Library/Frameworks/VideoSubscriberAccount.framework
Sep 21 13:32:34 jared-macbook com.apple.CoreSimulator.SimDevice.F0C11864-91E1-4323-AD01-BF9867279CEB.launchd_sim[32648] (com.apple.videosubscriptionsd[33182]): Service exited with abnormal code: 1

It seems to me that the issue is at
Class RCTCxxModule was not exported. Did you forget to use RCT_EXPORT_MODULE()?
in the system log, but I'm not sure.

Anyone have any ideas?

@vocampos
Copy link

I'm having the same problem on Android.

Any suggestion?

More details here, #96

Thank you

@LeoNatan
Copy link
Contributor

Hello,

We are moving support questions to Stack Overflow. Please ask a question there with the detox tag. This section is only meant for Detox issues and enhancement requests.

Thanks

@wildseansy
Copy link

wildseansy commented Apr 24, 2018

I'm using the latest version of detox (7.3.3), and this still seems to be an issue. I get detox-server wss 08:01:45: role=testee not connected, cannot fw action (sessionId=abcdef). This seems like the only post that actually discusses this problem. StackOverflow has a few questions, but no answers really yet.

When I run with the detox testing tools, (ios.none), it all works.

@LeoNatan
Copy link
Contributor

Please open a new issue and provide all required information. Thanks

@wildseansy
Copy link

wildseansy commented Apr 25, 2018

Submitted new ticket #689

@akqaaditya
Copy link

I am also facing same issue could anyone provide solution
test hanginh and after sometime only 2 line output
0 passing (2m)

  1. "before all" hook

node_modules/.bin/mocha e2e --opts e2e/mocha.opts --configuration ios.sim.debug --grep :android: --invert

(node:38487) ExperimentalWarning: The fs.promises API is experimental
before
detox-server info 17:33:20: server listening on localhost:62962...
detox info 1: Searching for device matching iPhone 8 Plus...
detox info 3: Uninstalling com.sephora.mcommerce.dev...
detox info 3: com.sephora.mcommerce.dev uninstalled
detox info 4: Installing /Users/aditya.pare/iOS/appofcards/ios/build/Build/Products/debug-iphonesimulator/appOfCard.app...
detox info 4: /Users/aditya.pare/iOS/appofcards/ios/build/Build/Products/debug-iphonesimulator/appOfCard.app installed
detox info 5: Terminating com.sephora.mcommerce.dev...
detox info 5: com.sephora.mcommerce.dev terminated
detox info 6: Launching com.sephora.mcommerce.dev...
detox info 6: com.sephora.mcommerce.dev launched. The stdout and stderr logs were recreated, you can watch them with:
tail -F $HOME/Library/Developer/CoreSimulator/Devices/CFD0C46C-6E2E-48C8-B795-F4BA1F061C73/data/tmp/detox.last_launch_app_log.{out,err}

0 passing (2m)

  1. "before all" hook

@illyax
Copy link

illyax commented Jun 6, 2018

If you running in expo, make sure hostType in .expo/settings.json is set to tunnel.

@ghost
Copy link

ghost commented Jun 15, 2018

@illyax did that, but the problem remains.
Did you managed to get expo to work with detox?

@wix wix locked and limited conversation to collaborators Jul 23, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests