Nativescript单元测试显示没有可访问的主机

时间:2016-10-24 16:57:10

标签: unit-testing nativescript

我正在尝试follow this tutorial使用Jasmine / Karma在Nativescript中进行单元测试。当我测试android时,我的手机闪烁,测试成功运行了大约一秒钟,但随后进入蓝屏,其中带有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测试android --watch并在手机上启动应用程序时,我会得到这个日志。

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)

应用程序仅闪烁显示测试结果,然后立即关闭。

1 个答案:

答案 0 :(得分:0)

看起来这是一个开放的bug