I'm trying to follow this tutorial to do unit testing in Nativescript with Jasmine/Karma. When I do tns test android, my phone flashes that the test ran succesfully for about a second, but then goes to a blue screen with the nativescript logo that says "no reachable hosts".
Here is the console log:
BUILD SUCCESSFUL
Total time: 10.693 secs
Successfully prepared plugin nativescript-unit-test-runner for android.
Project successfully prepared (android)
Executing after-prepare hook from D:\npn\natures-notebook-mobile\hooks\after-prepare\nativescript-unit-test-runner.js
Transferring project files...
Successfully transferred all files.
Applying changes...
Successfully synced application org.nativescript.naturesnotebookmobile on device TA9921AOKU.
JS: NSUTR: fetching http://myip:9876/context.json
JS: NSUTR: fetching http://127.0.0.1:9876/context.json
JS: NSUTR: found karma at myip
JS: NSUTR: connecting to karma at http://myip:9876
JS: NSUTR: successfully connected to karma
24 10 2016 09:43:00.395:INFO [NativeScript / 22 (5.1; XT1096)]: Connected on socket /#lsfwgpODsqXMa1AVAAAA with id NativeScriptUnit-5970
JS: NSUTR: downloading http://myip:9876/context.json
JS: NSUTR: disregarding second execution
JS: NSUTR: eval script /base/node_modules/jasmine-core/lib/jasmine-core/jasmine.js?916005cc407925f4764668d61d04888d59258f5d
JS: NSUTR: eval script /base/node_modules/karma-jasmine/lib/boot.js?945a38bf4e45ad2770eb94868231905a04a0bd3e
JS: NSUTR: eval script /base/node_modules/karma-jasmine/lib/adapter.js?7975a273517f1eb29d7bd018790fd4c7b9a485d5
JS: NSUTR: require script /base/app/tests/example.js?d4cad4cd203df70666c986cd09ce402b21d89b39 from ../../tests/example.js
JS: NSUTR: beginning test run
JS: NSUTR: completed test run.
NativeScript / 22 (5.1; XT1096): Executed 1 of 1 SUCCESS (0.111 secs / 0.01 secs)
JS: NSUTR: completeAck
JS: NSUTR-socket.io: io server disconnect
JS: NSUTR: fetching http://myip:9876/context.json
JS: NSUTR: fetching http://127.0.0.1:9876/context.json
I/art (16936): Rejecting re-init on previously-failed class java.lang.Class<com.android.webview.chromium.ServiceWorkerControllerAdapter>
I/art (16936): Rejecting re-init on previously-failed class java.lang.Class<com.android.webview.chromium.ServiceWorkerControllerAdapter>
I/art (16936): Rejecting re-init on previously-failed class java.lang.Class<com.android.webview.chromium.TokenBindingManagerAdapter>
I/art (16936): Rejecting re-init on previously-failed class java.lang.Class<com.android.webview.chromium.TokenBindingManagerAdapter>
Any ideas why this would be? tns info:
┌──────────────────┬─────────────────┬────────────────┬───────────────┐
│ Component │ Current version │ Latest version │ Information │
│ nativescript │ 2.3.0 │ 2.3.0 │ Up to date │
│ tns-core-modules │ 2.3.0 │ 2.3.0 │ Up to date │
│ tns-android │ 2.3.0 │ 2.3.0 │ Up to date │
│ tns-ios │ │ 2.3.0 │ Not installed
MORE INFO - When I run tns test android --watch and start up the app on the phone I get this log.
NativeScript / 22 (5.1; XT1096): Executed 1 of 1 SUCCESS (0.083 secs / 0.006 secs)
JS: NSUTR: fetching http://128.196.232.91:9876/context.json
JS: NSUTR: fetching http://10.142.143.93:9876/context.json
JS: NSUTR: fetching http://127.0.0.1:9876/context.json
JS: NSUTR: found karma at 128.196.232.91
JS: NSUTR: connecting to karma at http://128.196.232.91:9876
JS: NSUTR: successfully connected to karma
24 10 2016 15:54:26.854:INFO [NativeScript / 22 (5.1; XT1096)]: Connected on socket /#8bujUTl6BGLrcHa7AAAC with id NativeScriptUnit-55
JS: NSUTR: downloading http://128.196.232.91:9876/context.json
JS: NSUTR: eval script /base/node_modules/jasmine-core/lib/jasmine-core/jasmine.js?916005cc407925f4764668d61d04888d59258f5d
JS: NSUTR: eval script /base/node_modules/karma-jasmine/lib/boot.js?945a38bf4e45ad2770eb94868231905a04a0bd3e
JS: NSUTR: eval script /base/node_modules/karma-jasmine/lib/adapter.js?7975a273517f1eb29d7bd018790fd4c7b9a485d5
JS: NSUTR: require script /base/app/tests/example.js?d4cad4cd203df70666c986cd09ce402b21d89b39 from ../../tests/example.js
JS: NSUTR: beginning test run
JS: NSUTR: completed test run.
NativeScript / 22 (5.1; XT1096): Executed 1 of 1 SUCCESS (0.099 secs / 0.007 secs)
JS: NSUTR: completeAck
NativeScript / 22 (5.1; XT1096) ERROR
Disconnectedundefined
NativeScript / 22 (5.1; XT1096): Executed 1 of 1 SUCCESS (0.099 secs / 0.007 secs)
The app only flashes open showing the test results and then closes right away.
myipwhat is buthttp://127.0.0.1:9876/context.jsonpoints to mobile not existent thing, as on mobile you don't have server so change 127.0.0.1 to ip of pc or some server - Marek Maszayadb devicesortns deviceand verify the status of the device. - Nikolay Tsonev