Nativescript 单元测试显示没有可访问的主机
Nativescript unit testing shows no reachable hosts
我正在尝试 follow this tutorial 使用 Jasmine/Karma 在 Nativescript 中进行单元测试。当我进行 tns 测试 android 时,我的 phone 闪烁测试 运行 成功约一秒钟,但随后进入蓝屏并显示 "no reachable hosts" 的 nativescript 徽标.
这是控制台日志:
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>
知道为什么会这样吗? tns 信息:
┌──────────────────┬─────────────────┬────────────────┬───────────────┐
│ 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
更多信息 -
当我 运行 tns test android --watch 并在 phone 上启动应用程序时,我得到了这个日志。
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)
该应用程序仅会闪烁打开并显示测试结果,然后立即关闭。
看起来这是一个开放的bug。
我正在尝试 follow this tutorial 使用 Jasmine/Karma 在 Nativescript 中进行单元测试。当我进行 tns 测试 android 时,我的 phone 闪烁测试 运行 成功约一秒钟,但随后进入蓝屏并显示 "no reachable hosts" 的 nativescript 徽标.
这是控制台日志:
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>
知道为什么会这样吗? tns 信息:
┌──────────────────┬─────────────────┬────────────────┬───────────────┐
│ 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
更多信息 - 当我 运行 tns test android --watch 并在 phone 上启动应用程序时,我得到了这个日志。
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)
该应用程序仅会闪烁打开并显示测试结果,然后立即关闭。
看起来这是一个开放的bug。