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

Android gets stuck in detox.init() #1383

Closed
roeycollignon opened this issue May 14, 2019 · 6 comments
Closed

Android gets stuck in detox.init() #1383

roeycollignon opened this issue May 14, 2019 · 6 comments

Comments

@roeycollignon
Copy link

Describe the bug
After upgrading Detox to version 12.7.0, the App was launched but then gets stuck in detox.init()
This bug doesn't reproduce on version 10.0.7

To Reproduce

  • [V] I have tested this issue on the latest Detox release and it still reproduces

Expected behavior
The next step should be logging in to the App

Environment:

  • Detox: 12.7.0
  • React Native: 0.57.5
  • Node: 10.9.0
  • Device:
    Nexus 5X API 28
    Nexus 5X API 27
    Nexus 5X API 25
  • OS: Mac Mojave 14.0

Device and Verbose Detox Logs
`> [email protected] detox-android-sanity /Users/roey/fundbox/mobileNative

configuration="android.emu.release" RUNTIME_ENV="staging" cleanup=true artifactsLocation="./e2e/artifacts/" recordLogs="failing" takeScreenshots="all" recordVideos="all" node_modules/.bin/jest e2e/tests/sanity --config=e2e/config.json --maxWorkers=1 --verbose

Determining test suites to run...
console.log e2e/init.js:13

####################
      RUNNING DETOX...
####################

detox[26753] INFO: [DetoxServer.js] server listening on localhost:52692...
FAIL e2e/tests/sanity/sanityTests.spec.js (121.823s)
sanity suite
✕ verify the user can login (379ms)
○ skipped 1 test
after login
○ skipped 4 tests

● sanity suite › verify the user can login

Timeout - Async callback was not invoked within the 120000ms timeout specified by jest.setTimeout.

  at mapper (../node_modules/jest-jasmine2/build/queue_runner.js:41:52)

● sanity suite › verify the user can login

ReferenceError: device is not defined

  14 | describe("sanity suite", () => {
  15 |   beforeEach(async () => {
> 16 |     await device.reloadReactNative();
     |           ^
  17 |     const newUser = await callCaptainFunction(captain.CreateDemoUser.P0);
  18 |     email = newUser.email;
  19 |     fbbid = newUser.ids.fbbid;

  at Object.device (tests/sanity/sanityTests.spec.js:16:11)
  at tryCatch (../node_modules/@babel/runtime/node_modules/regenerator-runtime/runtime.js:62:40)
  at Generator.invoke [as _invoke] (../node_modules/@babel/runtime/node_modules/regenerator-runtime/runtime.js:288:22)
  at Generator.prototype.(anonymous function) [as next] (../node_modules/@babel/runtime/node_modules/regenerator-runtime/runtime.js:114:21)
  at tryCatch (../node_modules/@babel/runtime/node_modules/regenerator-runtime/runtime.js:62:40)
  at invoke (../node_modules/@babel/runtime/node_modules/regenerator-runtime/runtime.js:152:20)
  at ../node_modules/@babel/runtime/node_modules/regenerator-runtime/runtime.js:187:11
  at callInvokeWithMethodAndArg (../node_modules/@babel/runtime/node_modules/regenerator-runtime/runtime.js:186:16)
  at AsyncIterator.enqueue (../node_modules/@babel/runtime/node_modules/regenerator-runtime/runtime.js:209:13)
  at AsyncIterator.prototype.(anonymous function) [as next] (../node_modules/@babel/runtime/node_modules/regenerator-runtime/runtime.js:114:21)
  at Object.<anonymous>.runtime.async (../node_modules/@babel/runtime/node_modules/regenerator-runtime/runtime.js:233:14)
  at Object._callee (tests/sanity/sanityTests.spec.js:15:14)

● sanity suite › verify the user can login

ReferenceError: element is not defined

  11 |  * @param {string} password: The user's password
  12 |  */
> 13 | async function loginManually({ email, password = null }) {
     | ^
  14 |   const pass = password ? password : login.login.password;
  15 |   await element(by.id("loginEmailField")).replaceText(email);
  16 |   await element(by.id("loginPasswordField")).replaceText(pass);

  at loginManually$ (utils/applicationFlows.js:13:1)
  at tryCatch (../node_modules/@babel/runtime/node_modules/regenerator-runtime/runtime.js:62:40)
  at Generator.invoke [as _invoke] (../node_modules/@babel/runtime/node_modules/regenerator-runtime/runtime.js:288:22)
  at Generator.prototype.(anonymous function) [as next] (../node_modules/@babel/runtime/node_modules/regenerator-runtime/runtime.js:114:21)
  at tryCatch (../node_modules/@babel/runtime/node_modules/regenerator-runtime/runtime.js:62:40)
  at invoke (../node_modules/@babel/runtime/node_modules/regenerator-runtime/runtime.js:152:20)
  at ../node_modules/@babel/runtime/node_modules/regenerator-runtime/runtime.js:187:11
  at callInvokeWithMethodAndArg (../node_modules/@babel/runtime/node_modules/regenerator-runtime/runtime.js:186:16)
  at AsyncIterator.enqueue (../node_modules/@babel/runtime/node_modules/regenerator-runtime/runtime.js:209:13)
  at AsyncIterator.prototype.(anonymous function) [as next] (../node_modules/@babel/runtime/node_modules/regenerator-runtime/runtime.js:114:21)
  at Object.<anonymous>.runtime.async (../node_modules/@babel/runtime/node_modules/regenerator-runtime/runtime.js:233:14)
  at loginManually (utils/applicationFlows.js:13:1)
  at Object._callee2$ (tests/sanity/sanityTests.spec.js:23:11)
  at tryCatch (../node_modules/@babel/runtime/node_modules/regenerator-runtime/runtime.js:62:40)
  at Generator.invoke [as _invoke] (../node_modules/@babel/runtime/node_modules/regenerator-runtime/runtime.js:288:22)

● sanity suite › verify the user can login

TypeError: Cannot read property 'captainUrl' of undefined

  205 |  */
  206 | async function callCaptainFunction(functionReference, dataObject = {}) {
> 207 |   dataObject.captainUrl = global.urls.captainUrl;
      |                                       ^
  208 |   return await callTestingUtilsFunction(functionReference, dataObject);
  209 | }
  210 |

  at captainUrl (utils/helpers.js:207:39)
  at tryCatch (../node_modules/@babel/runtime/node_modules/regenerator-runtime/runtime.js:62:40)
  at Generator.invoke [as _invoke] (../node_modules/@babel/runtime/node_modules/regenerator-runtime/runtime.js:288:22)
  at Generator.prototype.(anonymous function) [as next] (../node_modules/@babel/runtime/node_modules/regenerator-runtime/runtime.js:114:21)
  at tryCatch (../node_modules/@babel/runtime/node_modules/regenerator-runtime/runtime.js:62:40)
  at invoke (../node_modules/@babel/runtime/node_modules/regenerator-runtime/runtime.js:152:20)
  at ../node_modules/@babel/runtime/node_modules/regenerator-runtime/runtime.js:187:11
  at callInvokeWithMethodAndArg (../node_modules/@babel/runtime/node_modules/regenerator-runtime/runtime.js:186:16)
  at AsyncIterator.enqueue (../node_modules/@babel/runtime/node_modules/regenerator-runtime/runtime.js:209:13)
  at AsyncIterator.prototype.(anonymous function) [as next] (../node_modules/@babel/runtime/node_modules/regenerator-runtime/runtime.js:114:21)
  at Object.<anonymous>.runtime.async (../node_modules/@babel/runtime/node_modules/regenerator-runtime/runtime.js:233:14)
  at callCaptainFunction (utils/helpers.js:206:1)
  at Object._callee9$ (tests/sanity/sanityTests.spec.js:61:11)
  at tryCatch (../node_modules/@babel/runtime/node_modules/regenerator-runtime/runtime.js:62:40)
  at Generator.invoke [as _invoke] (../node_modules/@babel/runtime/node_modules/regenerator-runtime/runtime.js:288:22)

● sanity suite › verify credit increase modal

Timeout - Async callback was not invoked within the 120000ms timeout specified by jest.setTimeout.

  at mapper (../node_modules/jest-jasmine2/build/queue_runner.js:41:52)

● sanity suite › after login › verify the user can logout

Timeout - Async callback was not invoked within the 120000ms timeout specified by jest.setTimeout.

  at mapper (../node_modules/jest-jasmine2/build/queue_runner.js:41:52)

● sanity suite › after login › clear with 12 weeks payment plan

Timeout - Async callback was not invoked within the 120000ms timeout specified by jest.setTimeout.

  at mapper (../node_modules/jest-jasmine2/build/queue_runner.js:41:52)

● sanity suite › after login › verify the user can change contact details

Timeout - Async callback was not invoked within the 120000ms timeout specified by jest.setTimeout.

  at mapper (../node_modules/jest-jasmine2/build/queue_runner.js:41:52)

● sanity suite › after login › repay the advance early

Timeout - Async callback was not invoked within the 120000ms timeout specified by jest.setTimeout.

  at mapper (../node_modules/jest-jasmine2/build/queue_runner.js:41:52)

Test Suites: 1 failed, 1 total
Tests: 1 failed, 5 skipped, 6 total
Snapshots: 0 total
Time: 121.872s, estimated 127s
Ran all test suites matching /e2e/tests/sanity/i.
jest-html-reporter >> Report generated (./e2e/artifacts/test-report.html)
Force exiting Jest

Have you considered using --detectOpenHandles to detect async operations that kept running after all tests finished?
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] detox-android-sanity: configuration="android.emu.release" RUNTIME_ENV="staging" cleanup=true artifactsLocation="./e2e/artifacts/" recordLogs="failing" takeScreenshots="all" recordVideos="all" node_modules/.bin/jest e2e/tests/sanity --config=e2e/config.json --maxWorkers=1 --verbose
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] detox-android-sanity script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR! /Users/roey/.npm/_logs/2019-05-14T11_10_32_294Z-debug.log

@matt-oakes
Copy link

I had this just now and it turned out to be that the Android Emulator was in Airplane Mode. You will get this "hang" if the emulator can't connect to the Detox server for some reason.

Your issue could be something else, but that fixed it for me.

@thabemmz
Copy link

thabemmz commented May 21, 2019

I'm having the same issue as described above. Remarkably, the detox tests do run correctly when I start the react-native server (by running react-native start) in another process.

Environment:

  • Detox: 12.8.0
  • React Native: 0.59.2
  • Node: 10.15.3
  • Device: Nexus 6P API 28
  • OS: Mac Mojave 10.14.5

Device and Verbose Detox Logs
Ran:

detox test -c android.emu.debug -l trace

Detox:

configuration="android.emu.debug" loglevel="trace" artifactsLocation="artifacts/android.emu.debug.2019-05-21 14-25-40Z" recordLogs="none" takeScreenshots="manual" recordVideos="none" recordPerformance="none" reportSpecs=true node_modules/.bin/jest --config=e2e/config.json --maxWorkers=1 '--testNamePattern=^((?!:ios:).)*$'

Detox trace:

detox[4686] TRACE: [ArtifactsManager.js/LIFECYCLE] artifactsManager.onLaunchApp({ deviceId: 'emulator-5554',
  bundleId: 'com.myapp',
  launchArgs:
   { '-e detoxServer': 'ws://localhost:51498',
     '-e detoxSessionId': '9b6c40c9-871b-17b0-2e87-35535a6859b4' },
  pid: 4686 })
detox[27676] TRACE: [AsyncWebSocket.js/WEBSOCKET_SEND] {"type":"isReady","params":{},"messageId":-1000}
detox[27676] TRACE: [DetoxServer.js/MESSAGE] role=tester action=isReady (sessionId=9b6c40c9-871b-17b0-2e87-35535a6859b4)
detox[27676] DEBUG: [DetoxServer.js/CANNOT_FORWARD] role=testee not connected, cannot fw action (sessionId=9b6c40c9-871b-17b0-2e87-35535a6859b4)
detox[27676] TRACE: [exec.js/SPAWN_STDOUT, #15] INSTRUMENTATION_STATUS: class=com.myapp.test.DetoxTest
INSTRUMENTATION_STATUS: current=1
INSTRUMENTATION_STATUS: id=AndroidJUnitRunner
INSTRUMENTATION_STATUS: numtests=1
INSTRUMENTATION_STATUS: stream=
com.myapp.test.DetoxTest:
INSTRUMENTATION_STATUS: test=runDetoxTests
INSTRUMENTATION_STATUS_CODE: 1

detox[27676] TRACE: [exec.js/SPAWN_STDOUT, #15] INSTRUMENTATION_RESULT: shortMsg=Process crashed.
INSTRUMENTATION_CODE: 0

detox[27676] DEBUG: [exec.js/KILL] sending SIGINT to [pid = 27715]: /Users/christiaanvanbemmel/Library/Android/sdk/platform-tools/adb -s emulator-5554 shell am instrument -w -r -e detoxServer ws://localhost:51498 -e detoxSessionId 9b6c40c9-871b-17b0-2e87-35535a6859b4 -e debug false com.myapp.test/androidx.test.runner.AndroidJUnitRunner
detox[27676] TRACE: [exec.js/SPAWN_END, #15] /Users/christiaanvanbemmel/Library/Android/sdk/platform-tools/adb -s emulator-5554 shell am instrument -w -r "-e detoxServer ws://localhost:51498 -e detoxSessionId 9b6c40c9-871b-17b0-2e87-35535a6859b4" -e debug false com.myapp.test/androidx.test.runner.AndroidJUnitRunner finished with code = 0

In adb logcat I found the following:

05-21 16:21:35.251  4848  4930 E AndroidRuntime: FATAL EXCEPTION: com.wix.detox.manager
05-21 16:21:35.251  4848  4930 E AndroidRuntime: Process: com.myapp, PID: 4848
05-21 16:21:35.251  4848  4930 E AndroidRuntime: java.lang.RuntimeException: waited a minute for the new reactContext
05-21 16:21:35.251  4848  4930 E AndroidRuntime: 	at com.wix.detox.ReactNativeSupport.waitForReactNativeLoad(ReactNativeSupport.java:154)
05-21 16:21:35.251  4848  4930 E AndroidRuntime: 	at com.wix.detox.ReactNativeCompat.waitForReactNativeLoad(ReactNativeCompat.java:33)
05-21 16:21:35.251  4848  4930 E AndroidRuntime: 	at com.wix.detox.DetoxManager.initReactNativeIfNeeded(DetoxManager.java:121)
05-21 16:21:35.251  4848  4930 E AndroidRuntime: 	at com.wix.detox.DetoxManager.start(DetoxManager.java:66)
05-21 16:21:35.251  4848  4930 E AndroidRuntime: 	at com.wix.detox.Detox$1$1.run(Detox.java:133)
05-21 16:21:35.251  4848  4930 E AndroidRuntime: 	at android.os.Handler.handleCallback(Handler.java:873)
05-21 16:21:35.251  4848  4930 E AndroidRuntime: 	at android.os.Handler.dispatchMessage(Handler.java:99)
05-21 16:21:35.251  4848  4930 E AndroidRuntime: 	at android.os.Looper.loop(Looper.java:193)
05-21 16:21:35.251  4848  4930 E AndroidRuntime: 	at com.wix.detox.Detox$1.run(Detox.java:136)
05-21 16:21:35.251  4848  4930 E AndroidRuntime: 	at java.lang.Thread.run(Thread.java:764)

Really spent a lot of time trying to match all files against the examples in the Detox repository, but nothing seems to work, except (like I described) running the detox testing with the metro bundler server running in the background.

@roeycollignon
Copy link
Author

I don't really know what caused this issue, but upgrading a lot of dependencies, compileSdkVersion, targetSdkVersion, etc in build gradle (especially firebase-core and firebase-messaging) solved it for me. Hope it will help you in any way to find your problem.

@wilau2
Copy link

wilau2 commented Jun 8, 2019

@roeycollignon can you be a bit more specific in the versions you upgraded to. I seem to experience the same issue.

@stale
Copy link

stale bot commented Jul 8, 2019

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!

For more information on bots in this reporsitory, read this discussion.

@stale stale bot added the 🏚 stale label Jul 8, 2019
@stale
Copy link

stale bot commented Jul 15, 2019

The issue has been closed for inactivity.

@stale stale bot closed this as completed Jul 15, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Jul 18, 2019
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

5 participants