tns 测试 android 在同步到设备后挂起

tns test android hangs after synced to device

我目前正尝试在我的 nativescript 项目上设置单元测试。我正在使用带有 chai 的 mocha 作为我的测试框架并且 运行 tns test init 一切正常。

当我 运行 tns test android 每隔 运行 正常并且模拟器启动时。但是,在将应用程序同步到我的模拟器(也可以正常启动)后,它挂在:

JS: NSUTR: fetching http://***.***.**.*:9876/context.json
JS: NSUTR: fetching http://***.***.*.**:9876/context.json
JS: NSUTR: fetching http://127.0.0.1:9876/context.json

我尝试了一些不同的东西,运行宁 tns test android --debug-brk 看看它失败的地方。这表示 Error: Could not find device by specified identifier 'undefined' 但模拟器 运行 正常,因为命令已启动它,我可以看到模拟器使用 tns device.

非常感谢任何帮助,谢谢。

android:usesCleartextTraffic="true" 添加到 Android Manifest<application 文件似乎已经解决了找不到 Karma 服务器的问题。

https://github.com/NativeScript/nativescript-cli/issues/4182

我使用的是 nativescript 版本 4.2.0 所以最新版本可能已经解决了这个问题。