Skip to content

$ tns test android test harness reports "no reachable hosts" #4182

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

Closed
groksrc opened this issue Nov 29, 2018 · 3 comments
Closed

$ tns test android test harness reports "no reachable hosts" #4182

groksrc opened this issue Nov 29, 2018 · 3 comments

Comments

@groksrc
Copy link

groksrc commented Nov 29, 2018

Environment
Provide version numbers for the following components (information can be retrieved by running tns info in your project folder or by inspecting the package.json of the project):

  • CLI: 5.0.1
  • Cross-platform modules: 5.0.5
  • Android Runtime: 5.0.0
  • iOS Runtime: 5.0.0
  • Plugin(s): None

Describe the bug
I'm trying to set up unit tests in a brand new project and run on an android emulator. When running the steps to reproduce the test harness starts but then reports "no reachable hosts" and hangs. The output from the terminal is:

$ tns test android
Searching for devices...
Starting Android emulator with image Pixel_2_API_28
Waiting for emulator device initialization...
28 11 2018 19:48:42.468:WARN [karma]: No captured browser, open http://localhost:9876/
28 11 2018 19:48:42.473:INFO [karma-server]: Karma v3.1.1 server started at http://0.0.0.0:9876/
28 11 2018 19:48:42.473:INFO [launcher]: Launching browsers android with concurrency unlimited
28 11 2018 19:48:42.477:INFO [launcher]: Starting browser NativeScript Unit Test Runner
Copying template files...
Platform android successfully added. v5.0.0
Executing before-shouldPrepare hook from /Users/drewcain/code/testandroid/hooks/before-shouldPrepare/nativescript-dev-webpack.js
Preparing project...
Executing before-prepareJSApp hook from /Users/drewcain/code/testandroid/hooks/before-prepareJSApp/nativescript-dev-webpack.js
Successfully prepared plugin nativescript-theme-core for android.
Successfully prepared plugin nativescript-unit-test-runner for android.
Successfully prepared plugin nativescript-vue for android.
Successfully prepared plugin tns-core-modules for android.
Successfully prepared plugin tns-core-modules-widgets for android.
Project successfully prepared (android)
Executing after-prepare hook from /Users/drewcain/code/testandroid/hooks/after-prepare/nativescript-dev-webpack.js
Executing after-prepare hook from /Users/drewcain/code/testandroid/hooks/after-prepare/nativescript-unit-test-runner.js
Executing before-watchPatterns hook from /Users/drewcain/code/testandroid/hooks/before-watchPatterns/nativescript-dev-webpack.js
Executing before-watch hook from /Users/drewcain/code/testandroid/hooks/before-watch/nativescript-dev-webpack.js
Executing before-shouldPrepare hook from /Users/drewcain/code/testandroid/hooks/before-shouldPrepare/nativescript-dev-webpack.js
Skipping prepare.
Building project...
Gradle build...
         + setting applicationId
         + applying user-defined configuration from /Users/drewcain/code/testandroid/app/App_Resources/Android/app.gradle
Using support library version 28.0.0
         + adding nativescript runtime package dependency: nativescript-optimized-with-inspector
         + adding aar plugin dependency: /Users/drewcain/code/testandroid/node_modules/tns-core-modules-widgets/platforms/android/widgets-release.aar
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Project successfully built.
Installing on device emulator-5554...
Successfully installed on device with identifier 'emulator-5554'.
Refreshing application on device emulator-5554...
Successfully synced application org.nativescript.testandroid on device emulator-5554.
JS: NSUTR: fetching http://127.0.0.1:9876/context.json
JS: NSUTR: fetching http://192.168.2.158:9876/context.json

I have also tried the --justlaunch flag but that doesn't have any impact.

To Reproduce

$ tns create
? First, what will be the name of your app? testandroid
❯ Vue.js            |  Learn more at https://nativescript.org/vue

$ cd testandroid
$ npm i
$ tns test init
❯ mocha

$ tns test android

Expected behavior
The test run completes with success and returns zero.

Sample project
https://github.com/groksrc/testandroid

Additional context
I have gone as far as recreating my android emulator just to make sure there wasn't something going on there. I am not behind a proxy and I do not have any network restrictions in place that may prevent communication between the processes. Running for iOS works as expected. I am on macOS High Sierra 10.13.6

$ tns test ios --justlaunch
Searching for devices...
28 11 2018 20:04:42.822:INFO [karma-server]: Karma v3.1.1 server started at http://0.0.0.0:9876/
28 11 2018 20:04:42.824:INFO [launcher]: Launching browsers ios with concurrency unlimited
28 11 2018 20:04:42.830:INFO [launcher]: Starting browser NativeScript Unit Test Runner
Executing before-shouldPrepare hook from /Users/drewcain/code/testandroid/hooks/before-shouldPrepare/nativescript-dev-webpack.js
Executing before-cleanApp hook from /Users/drewcain/code/testandroid/hooks/before-cleanApp/nativescript-dev-webpack.js
Preparing project...
Executing before-prepareJSApp hook from /Users/drewcain/code/testandroid/hooks/before-prepareJSApp/nativescript-dev-webpack.js
Project successfully prepared (ios)
Executing after-prepare hook from /Users/drewcain/code/testandroid/hooks/after-prepare/nativescript-dev-webpack.js
Executing after-prepare hook from /Users/drewcain/code/testandroid/hooks/after-prepare/nativescript-unit-test-runner.js
Executing before-shouldPrepare hook from /Users/drewcain/code/testandroid/hooks/before-shouldPrepare/nativescript-dev-webpack.js
Skipping prepare.
Building project...
Xcode build...
Project successfully built.
Installing on device 960E5714-9A61-4FDB-958F-969910F95D87...
Successfully installed on device with identifier '960E5714-9A61-4FDB-958F-969910F95D87'.
Successfully transferred all files on device 960E5714-9A61-4FDB-958F-969910F95D87.
Refreshing application on device 960E5714-9A61-4FDB-958F-969910F95D87...
Successfully synced application org.nativescript.testandroid on device 960E5714-9A61-4FDB-958F-969910F95D87.
28 11 2018 20:05:02.229:INFO [NativeScript / 12.1 (12.1; iPhone)]: Connected on socket Io9b362ScDWx7E7SAAAA with id NativeScriptUnit-4165
NativeScript / 12.1 (12.1; iPhone): Executed 1 of 1 SUCCESS (0.008 secs / 0 secs)
TOTAL: 1 SUCCESS
@groksrc groksrc changed the title tns test android test harness reports "no reachable hosts" $ tns test android test harness reports "no reachable hosts" Nov 29, 2018
@Fatme
Copy link
Contributor

Fatme commented Nov 29, 2018

@groksrc,

You need to add android:usesCleartextTraffic="true" in App_Resources/android/AndroidManifest.xml.

<application
         android:usesCleartextTraffic="true"

@groksrc
Copy link
Author

groksrc commented Nov 29, 2018

@Fatme,

That did allow the test run to complete as expected. Ideally that attribute would not need to be set for my application and manual configuration to get the tests to run would not be necessary, but it is working.

Many thanks!

@Fatme
Copy link
Contributor

Fatme commented Nov 29, 2018

@groksrc,

I'm closing this as a duplicate to #4119

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants