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.
Test is hanging on before hook.
before(async () => {
await detox.init(config); // hangs here
});
"detox": {
"configurations": {
"ios.sim.debug.stg": {
"binaryPath": "Build/iOS/Debug-stg-iphonesimulator/{appName}.app",
"type": "ios.simulator",
"name": "iPhone X"
}
},
"test-runner": "mocha"
},
Running: detox test --loglevel trace
node_modules/.bin/mocha e2e --opts e2e/mocha.opts --configuration ios.sim.debug.stg --loglevel trace --grep :android: --invert --artifacts-location "artifacts/ios.sim.debug.stg.2018-10-30 03-14-38Z"
detox[6877] INFO: [DetoxServer.js] server listening on localhost:51088...
detox[6877] DEBUG: [AsyncWebSocket.js/WEBSOCKET_OPEN] opened web socket to: ws://localhost:51088
detox[6877] TRACE: [AsyncWebSocket.js/WEBSOCKET_SEND] {"type":"login","params":{"sessionId":"d58e4eb7-6354-4a2e-4c1a-5551a972f850","role":"tester"},"messageId":0}
detox[6877] DEBUG: [DetoxServer.js/LOGIN] role=tester, sessionId=d58e4eb7-6354-4a2e-4c1a-5551a972f850
detox[6877] DEBUG: [DetoxServer.js/LOGIN_SUCCESS] role=tester, sessionId=d58e4eb7-6354-4a2e-4c1a-5551a972f850
detox[6877] TRACE: [AsyncWebSocket.js/WEBSOCKET_MESSAGE] {"type":"loginSuccess","params":{"sessionId":"d58e4eb7-6354-4a2e-4c1a-5551a972f850","role":"tester"},"messageId":0}
I'm seeing same issue 馃槦App is launched. But tests are not started.
detox[66653] TRACE: [AsyncWebSocket.js/WEBSOCKET_SEND] {"type":"isReady","params":{},"messageId":-1000}
detox[66653] TRACE: [DetoxServer.js/MESSAGE] role=tester action=isReady (sessionId=1a83b092-7b18-60c2-49a3-bc3cd3bb1ef4)
detox[66653] DEBUG: [DetoxServer.js/CANNOT_FORWARD] role=testee not connected, cannot fw action (sessionId=1a83b092-7b18-60c2-49a3-bc3cd3bb1ef4)
detox[66653] DEBUG: [DetoxServer.js/LOGIN] role=testee, sessionId=1a83b092-7b18-60c2-49a3-bc3cd3bb1ef4
detox[66653] DEBUG: [DetoxServer.js/LOGIN_SUCCESS] role=testee, sessionId=1a83b092-7b18-60c2-49a3-bc3cd3bb1ef4
Detox: 9.0.5
Node: 9.2.1
Device: iPhone 7
Xcode: 10.0
applesimutils: 0.5.19
macOS: High Sierra 10.13.6
react-navigation: 2.17.0
Whoever is experiencing this issue, check if your application ever goes idle.
We had a recursive function that used setTimeout to achieve some continues background animations. What we had to do is to disable those transitions while testing and detox was able to start successfully.
@KostasKostogloy lifesaver 鉂わ笍, I have some animations running in loop (with Animated.loop) which makes detox wait for some reason. Now the question is how to test the app without the need of disabling this 馃
Any ideas how to get something like process.env.NODE_ENV === "test" while running detox tests ?
I also have an Animated looping view which is making the detox tests hang.
@KevinGulj I'm planing to use this for other things but maybe it helps: https://github.com/luggit/react-native-config ?
Let me know if you manage 馃槉
@KevinGulj I'm planing to use this for other things but maybe it helps: https://github.com/luggit/react-native-config ?
Let me know if you manage 馃槉
Thanks a lot @rborn , thats exactly what I needed and it works fine :)
Running it like so:
"test-ios": "ENVFILE=.env.testing detox build --configuration ios.sim.debug && detox test --configuration ios.sim.debug",
Detox runs on two sides, your test code in node on one side and inside JavaScriptCore engine running in your app. Your app code will never be affected by env vars of your dev machine.
To mock inside your app you'll need to set metro to build different flavours of your app
https://github.com/wix/Detox/blob/master/docs/Guide.Mocking.md
If you use react native navigation you can also pass launch args and get them in runtime inside the app.
https://github.com/wix/react-native-navigation/commit/d86a63cd290f96310b5748c8c1e19f85295a1ac7
Detox runs on two sides, your test code in node on one side and inside JavaScriptCore engine running in your app. Your app code will never be affected by env vars of your dev machine.
To mock inside your app you'll need to set metro to build different flavours of your app
https://github.com/wix/Detox/blob/master/docs/
You could use native code for passing on the env variables to the JavaScriptCore engine. Which is what https://github.com/luggit/react-native-config does. And it works fine, very easy to use and flexible :)
Yea, but it seems like it requires compilation for every change, these are not env vars, but static config.
Passing launch args to detox can mean you'll be able to run multiple tests with different launch args in each, without recompiling.
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.
The issue has been closed for inactivity.
Most helpful comment
I'm seeing same issue 馃槦App is launched. But tests are not started.
Detox: 9.0.5
Node: 9.2.1
Device: iPhone 7
Xcode: 10.0
applesimutils: 0.5.19
macOS: High Sierra 10.13.6
react-navigation: 2.17.0