Detox: Tests hanging on before_all hook
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"
}
}
}
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 5
- Comments: 71 (20 by maintainers)
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
RCTContentDidAppearNotificationnotification 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
RCTContentDidAppearNotificationfire 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
RCTContentDidAppearNotificationafter we’ve finished downloading ourjsbundle: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.
@vspedr nope, no CodePush
Hey, I’m having the same issue.
Version:
My config in
package.json:I run
detox testafter building withreact-native run-ios. It starts to run, and the app immediately crashes.For me, it also hangs in
init.jsAnd the result in the terminal:
The output from my system log is
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?
@rotemmiz 8.2.1
I’ve checked out the repo and am currently taking a look. It gets stuck in
./detox/src/client/Client.jsinside thesendActionfn on this line:const response = await this.ws.send(action, messageId)It never resolves. I’ve noticed the
AsyncWebSockethas changed, and doesn’t resolve if there is nopendingPromise. Not sure if that might have something to do with it. Still trying to make sense of how Detox works@fighterpoul @adamski Guys, why are you building with the
ARCHS=i386in 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.
Hi guys. I had exactly this same issue. I don’t remember why but I needed to build my app for tests with
ARCHS=i386flag. I had seen error log like thisdyld: warning: could not load inserted library '/path/to/app/node_modules/detox/Detox.framework/Detox' because no suitable image found. Did find: /path/to/app/node_modules/detox/Detox.framework/Detox: no matching architecture in universal wrapperwhen I was running the build. I solved the issue by making sure that dependencies (fbsimctl etc.) are installed well by reinstalling them ( 😃 ) and by removing the flag. I was inspired by example demo application in examples folder. I hope it’ll help you all.No CodePush here either. I’m using RN via CocoaPods, if that might make a difference?
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
I think Detox tries to throw an error inside mocha’s
beforeAllhook , but for some reason mocha catches all errors thrown insidebeforeAll. As a workaround, try surroundingdetox.init()with a try/catch clause, and print the exception. What does it say ?@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:
By the way, I’m using react native version 0.44.2