android - 我一直在尝试在 nativescript 应用程序中运行一些单元测试,但它抛出了 typeError Cannot set property '_moduleName' of undefined
问题描述
我花了几天时间尝试在我的 nativescript 应用程序上运行示例单元测试,但测试没有运行。当我执行命令时
tns run android
该应用程序运行良好。
错误只是在我运行时发生
tns test android
更多信息
"dependencies": {
"nativescript-theme-core": "~1.0.4",
"nativescript-unit-test-runner": "^0.7.0",
"tns-core-modules": "~5.3.0"
},
"devDependencies": {
"@types/karma-chai": "0.1.1",
"@types/mocha": "5.2.6",
"chai": "4.2.0",
"karma": "4.3.0",
"karma-chai": "0.1.0",
"karma-mocha": "1.3.0",
"karma-nativescript-launcher": "0.4.0",
"karma-webpack": "3.0.5",
"mocha": "6.1.4",
"nativescript-dev-typescript": "~0.9.0",
"nativescript-dev-webpack": "~0.21.0"
}
这是测试示例
describe('Array', function () {
describe('#indexOf()', function () {
it('should return -1 when the value is not present', function () {
assert.equal(-1, [1, 2, 3].indexOf(5));
assert.equal(-1, [1, 2, 3].indexOf(0));
});
});
})
这是错误日志
Found peer TypeScript 3.1.6
07 09 2019 14:42:33.089:INFO [filelist]: Changed file "/home/jnovas/NativescriptProj/nativescript-app/demo/app/tests/example.js".
07 09 2019 14:42:33.343:WARN [karma]: No captured browser, open http://localhost:9876/
Preparing project...
Project successfully prepared (Android)
Installing on device emulator-5554...
Successfully installed on device with identifier 'emulator-5554'.
Restarting application on device emulator-5554...
Successfully synced application org.nativescript.demo on device emulator-5554.
System.err: java.lang.RuntimeException: Unable to start activity ComponentInfo{org.nativescript.demo/com.tns.NativeScriptActivity}: com.tns.NativeScriptException:
System.err: Calling js method onCreate failed
System.err:
System.err: TypeError: Cannot set property '_moduleName' of undefined
System.err: File: "file:///data/data/org.nativescript.demo/files/app/tns_modules/tns-core-modules/ui/builder/builder.js, line: 111, column: 30
System.err:
System.err: StackTrace:
System.err: Frame: function:'markAsModuleRoot', file:'file:///data/data/org.nativescript.demo/files/app/tns_modules/tns-core-modules/ui/builder/builder.js', line: 111, column: 31
System.err: Frame: function:'loadPage', file:'file:///data/data/org.nativescript.demo/files/app/tns_modules/tns-core-modules/ui/builder/builder.js', line: 55, column: 5
System.err: Frame: function:'', file:'file:///data/data/org.nativescript.demo/files/app/tns_modules/tns-core-modules/ui/builder/builder.js', line: 74, column: 12
System.err: Frame: function:'', file:'file:///data/data/org.nativescript.demo/files/app/tns_modules/tns-core-modules/ui/builder/builder.js', line: 88, column: 20
System.err: Frame: function:'ActivityCallbacksImplementation.setActivityContent', file:'file:///data/data/org.nativescript.demo/files/app/tns_modules/tns-core-modules/ui/frame/frame.js', line: 935, column: 42
System.err: Frame: function:'ActivityCallbacksImplementation.onCreate', file:'file:///data/data/org.nativescript.demo/files/app/tns_modules/tns-core-modules/ui/frame/frame.js', line: 768, column: 14
System.err: Frame: function:'NativeScriptActivity.onCreate', file:'file:///data/data/org.nativescript.demo/files/app/tns_modules/tns-core-modules/ui/frame/activity.js', line: 20, column: 25
System.err:
System.err: at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2913)
有人遇到同样的错误吗?
解决方案
推荐阅读
- powershell - Powershell 变量未用作变量
- compression - Are Linear Quadtrees the most efficient way to store grid division data
- javascript - 未捕获的 ReferenceError:未定义 y (var)
- php - 将 $date 从 wordpress 中的高级自定义字段转换为 php 格式
- java - 带有 java 后端的 Git 克隆 Web 应用程序
- r - 股票价格数据的合计 5 分钟间隔
- bash - 用 cut 过滤 ping 的输出
- jmespath - JMESPath - 连接嵌套数组中的项目
- java - Java 在货币表示和货币转换方面的表现?
- c# - 正在修改什么集合?收藏已修改;枚举操作可能无法执行