Hi,
I am running Detox with expo (app standalone, project contains native ios and android modules).
I face with scenario where app is correctly installed but during debugging I discovered that Detox does not go further than await detox.init(config); from init.js file.
Environment:
mac 10.13
=> npm version:
6.1.0
=> node version:
v10.6.0
=> carthage version:
Please update to the latest Carthage version: 0.30.1. You currently are on 0.29.0
0.29.0
=> pod version:
1.5.3
=> exp version:
55.0.5
=> XCode version:
Xcode 9.4.1
Build version 9F2000
logs:
MacBook-Pro-Adam:mobile-project-final adamstasiak$ detox test -l verbose
node_modules/.bin/mocha e2e --opts e2e/mocha.opts --configuration ios.sim.debug --loglevel verbose --grep :android: --invert --artifacts-location "artifacts/ios.sim.debug.2018-08-31 12-19-59Z"
detox[80418] INFO: [DetoxServer.js] server listening on localhost:53225...
detox[80418] DEBUG: [AsyncWebSocket.js/WEBSOCKET_OPEN] opened web socket to: ws://localhost:53225
detox[80418] DEBUG: [DetoxServer.js/LOGIN] role=tester, sessionId=8896fd7f-270d-e893-f776-b590aac5fccb
detox[80418] DEBUG: [DetoxServer.js/LOGIN_SUCCESS] role=tester, sessionId=8896fd7f-270d-e893-f776-b590aac5fccb
detox[80418] DEBUG: [exec.js/EXEC_CMD, #0] /usr/bin/xcrun simctl list -j
detox[80418] DEBUG: [exec.js/EXEC_CMD, #1] applesimutils --list --byType "iPhone 8" --byOS "11.4"
detox[80418] DEBUG: [exec.js/EXEC_TRY, #1] Searching for device matching iPhone 8...
detox[80418] DEBUG: [exec.js/EXEC_CMD, #2] applesimutils --list --byId "14D76F42-23F6-4737-9F51-CCD34FD024C4"
detox[80418] DEBUG: [exec.js/EXEC_CMD, #3] /usr/bin/xcrun simctl uninstall 14D76F42-23F6-4737-9F51-CCD34FD024C4 io.project
detox[80418] DEBUG: [exec.js/EXEC_TRY, #3] Uninstalling io.project...
detox[80418] DEBUG: [exec.js/EXEC_SUCCESS, #3] io.project uninstalled
detox[80418] DEBUG: [exec.js/EXEC_CMD, #4] /usr/bin/xcrun simctl install 14D76F42-23F6-4737-9F51-CCD34FD024C4 "/Users/adamstasiak/repo-project-final/ios/build/Build/Products/Debug-iphonesimulator/mobile.app"
detox[80418] DEBUG: [exec.js/EXEC_TRY, #4] Installing /Users/adamstasiak/mobile-project-final/ios/build/Build/Products/Debug-iphonesimulator/mobile.app...
detox[80418] DEBUG: [exec.js/EXEC_SUCCESS, #4] /Users/adamstasiak/mobile-project-final/ios/build/Build/Products/Debug-iphonesimulator/mobile.app installed
detox[80418] DEBUG: [exec.js/EXEC_CMD, #5] /usr/bin/xcrun simctl terminate 14D76F42-23F6-4737-9F51-CCD34FD024C4 io.project
detox[80418] DEBUG: [exec.js/EXEC_TRY, #5] Terminating io.project...
detox[80418] DEBUG: [exec.js/EXEC_SUCCESS, #5] io.project terminated
detox[80418] DEBUG: [exec.js/EXEC_CMD, #6] /bin/cat /dev/null >/Users/adamstasiak/Library/Developer/CoreSimulator/Devices/14D76F42-23F6-4737-9F51-CCD34FD024C4/data/tmp/detox.last_launch_app_log.out 2>/Users/adamstasiak/Library/Developer/CoreSimulator/Devices/14D76F42-23F6-4737-9F51-CCD34FD024C4/data/tmp/detox.last_launch_app_log.err && SIMCTL_CHILD_DYLD_INSERT_LIBRARIES="/Users/adamstasiak/Library/Detox/ios/9b1cf119d6b7b0d2bb09a9e8c56ad526925d9c30/Detox.framework/Detox" /usr/bin/xcrun simctl launch --stdout=/tmp/detox.last_launch_app_log.out --stderr=/tmp/detox.last_launch_app_log.err 14D76F42-23F6-4737-9F51-CCD34FD024C4 io.project --args -detoxServer ws://localhost:53225 -detoxSessionId 8896fd7f-270d-e893-f776-b590aac5fccb
detox[80418] DEBUG: [exec.js/EXEC_TRY, #6] Launching io.project...
detox[80418] DEBUG: [exec.js/EXEC_SUCCESS, #6] io.project launched. The stdout and stderr logs were recreated, you can watch them with:
tail -F /Users/adamstasiak/Library/Developer/CoreSimulator/Devices/14D76F42-23F6-4737-9F51-CCD34FD024C4/data/tmp/detox.last_launch_app_log.{out,err}
detox[80418] DEBUG: [DetoxServer.js/CANNOT_FORWARD] role=testee not connected, cannot fw action (sessionId=8896fd7f-270d-e893-f776-b590aac5fccb)
detox[80418] DEBUG: [DetoxServer.js/LOGIN] role=testee, sessionId=8896fd7f-270d-e893-f776-b590aac5fccb
detox[80418] DEBUG: [DetoxServer.js/LOGIN_SUCCESS] role=testee, sessionId=8896fd7f-270d-e893-f776-b590aac5fccb
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.
detox[80418] DEBUG: [DetoxServer.js/DISCONNECT] role=tester, sessionId=8896fd7f-270d-e893-f776-b590aac5fccb
detox[80418] DEBUG: [DetoxServer.js/DISCONNECT] role=testee, sessionId=8896fd7f-270d-e893-f776-b590aac5fccb
child_process.js:643
throw err;
^
Error: Command failed: node_modules/.bin/mocha e2e --opts e2e/mocha.opts --configuration ios.sim.debug --loglevel verbose --grep :android: --invert --artifacts-location "artifacts/ios.sim.debug.2018-08-31 12-19-59Z"
at checkExecSyncError (child_process.js:603:11)
at Object.execSync (child_process.js:640:13)
at runMocha (/Users/adamstasiak/mobile-project-final/detox/local-cli/detox-test.js:129:6)
at run (/Users/adamstasiak/mobile-project-final/detox/local-cli/detox-test.js:82:7)
at Object.<anonymous> (/Users/adamstasiak/mobile-project-final/detox/local-cli/detox-test.js:217:1)
at Module._compile (internal/modules/cjs/loader.js:689:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
at Module.load (internal/modules/cjs/loader.js:599:32)
at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
at Function.Module._load (internal/modules/cjs/loader.js:530:3)
One of my assumptions was that React Native version that comes with expo sdk 27 is 55.2 and Detox does not support this but I also tried code of Detox that supports React Native 56.
I tried option with detox-helper from @peterpme but I think it is more for projects without native modules (maybe I am wrong but when my app is correctly launched then I should no need helpers).
My config for detox is:
"detox": {
"test-runner": "mocha",
"configurations": {
"ios.sim.debug": {
"binaryPath": "ios/build/Build/Products/Debug-iphonesimulator/mobile.app",
"build": "xcodebuild -workspace ios/mobile.xcworkspace -scheme mobile -configuration Debug -sdk iphonesimulator -derivedDataPath ios/build",
"type": "ios.simulator",
"name": "iPhone 8"
}
}
}
Other files are not modified. Detox version is 8.2.3.
Detox on iOS should support 0.56 as far as I know.
Try running your test with --debug-synchronization 1000 and paste the output of that here. Thanks
Tried with mentioned flag and output is the same. @LeoNatan
@LeoNatan and @adam-stasiak ok I've done some digging around and looked at the repo @brentvatne wrote a year ago. Looks like it hangs on this line:
https://github.com/expo/detox-expo-helpers/blob/master/index.js#L23
It seems to actually relaunch the app and do the deep link correctly. But that await doesn't return at that point.
I suspect it might have to do with the web socket connection Expo establishes to monitor for live reload. The line following are trying to blacklist some of those, but I think it is too late at that point.
To make it easier for us to test here is a sample repo I've been working on: https://github.com/yagudaev/detox-experiment -- it's a simple repo with a login page that I am trying to fill in. Followed the guide to get it setup this one.
I don't quite know enough about the inner workings of Expo app and Detox. But it would love to help get this to work with a bit of your help.
@yagudaev, just to clarify. Your repo can reproduce the issue currently, right?
@noomorph I have some additional observations. As @brentvatne previously alluded when implementing detox-expo-helpers, livereload had to be blacklisted as to avoid Detox "hanging".
It seems that this is may no longer be working? Disabling livereload manually in the expo devmenu allows detox to proceed when used in conjunction with --reuse flag, but later detox is stuck again as await this.deviceDriver.waitUntilReady(); doesn't resolve. That is until you open the devmenu then it finally resolves.
Has there been any traction on this by anyone? We're evaluating detox for our expo app and I'm coming up against this exact scenario with zero success.
@cem2ran any new insights you care to share?
cc @quinlanj
i'm in @arvinsingla's boat; just ran up against this while evaluating.
As has been stated in other issues the tests run correctly in 7.2.0 or lower. This is obviously not ideal. If i have time tomorrow I'm going to go through the comparison of changes between 7.3.0 and 7.2.0 to see if anything stands out, but I really don't have much of a clue what I'm looking for.
this should be fixed once we land https://github.com/expo/detox-expo-helpers/pull/9
@arvinsingla Would it work for you to run detox tests on a standalone expo build/binary for the simulator as opposed to an Expo binary? Please see my comment here https://github.com/expo/expo/issues/584#issuecomment-435280302
hi all, this issue should be fixed now. see https://github.com/expo/with-detox-tests for a working example
@quinlanj Thank you for the quality contributions!
Most helpful comment
@noomorph I have some additional observations. As @brentvatne previously alluded when implementing detox-expo-helpers, livereload had to be blacklisted as to avoid Detox "hanging".
It seems that this is may no longer be working? Disabling livereload manually in the expo devmenu allows detox to proceed when used in conjunction with
--reuseflag, but later detox is stuck again asawait this.deviceDriver.waitUntilReady();doesn't resolve. That is until you open the devmenu then it finally resolves.