测试似乎在模拟器中运行,因为应用程序启动时会短暂显示“正在测试”,然后是“总计:0,通过:0,失败:0”(拍摄了模拟器窗口的视频)。
这是一个使用 TypeScript 的 NativeScript Angular 项目。我已经尝试了一个示例,src/app/tests/example.js
并且src/app/tests/example.ts
具有以下内容:
// A sample Jasmine test
describe('A suite', () => {
it('contains spec with an expectation', () => {
expect(true).toBe(true);
});
});
运行后的最后几行日志tns test ios
。
Skipping prepare.
Successfully transferred all files.
Refreshing application...
Successfully synced application [redacted] on device CFB71B33-F348-452D-8069-E846D46A246D.
CONSOLE LOG file:///app/tns_modules/nativescript-unit-test-runner/main-view-model.js:54:28: NSUTR: fetching http://127.0.0.1:9876/context.json
CONSOLE LOG file:///app/tns_modules/nativescript-unit-test-runner/main-view-model.js:54:28: NSUTR: fetching http://10.0.1.15:9876/context.json
CONSOLE LOG file:///app/tns_modules/nativescript-unit-test-runner/main-view-model.js:60:32: NSUTR: found karma at 127.0.0.1
CONSOLE LOG file:///app/tns_modules/nativescript-unit-test-runner/main-view-model.js:97:20: NSUTR: connecting to karma at http://127.0.0.1:9876
CONSOLE LOG file:///app/tns_modules/nativescript-unit-test-runner/main-view-model.js:60:32: NSUTR: found karma at 10.0.1.15
CONSOLE LOG file:///app/tns_modules/nativescript-unit-test-runner/main-view-model.js:116:24: NSUTR: successfully connected to karma
08 10 2018 15:56:45.224:INFO [NativeScript / 11.4 (11.4; iPhone)]: Connected on socket 1gPBBxKC1KDaVXesAAAA with id NativeScriptUnit-3023
CONSOLE LOG file:///app/tns_modules/nativescript-unit-test-runner/main-view-model.js:159:20: NSUTR: downloading http://127.0.0.1:9876/context.json
CONSOLE LOG file:///app/tns_modules/nativescript-unit-test-runner/main-view-model.js:200:32: NSUTR: eval script /base/node_modules/jasmine-core/lib/jasmine-core/jasmine.js?a1eb923d36d1ca53b93387cb5312668373ad9ef2
CONSOLE LOG file:///app/tns_modules/nativescript-unit-test-runner/main-view-model.js:200:32: NSUTR: eval script /base/node_modules/karma-jasmine/lib/boot.js?945a38bf4e45ad2770eb94868231905a04a0bd3e
CONSOLE LOG file:///app/tns_modules/nativescript-unit-test-runner/main-view-model.js:200:32: NSUTR: eval script /base/node_modules/karma-jasmine/lib/adapter.js?6cf71867f538f40db053c1775b2c56a83696375c
CONSOLE LOG file:///app/tns_modules/nativescript-unit-test-runner/main-view-model.js:212:24: NSUTR: beginning test run
NativeScript / 11.4 (11.4; iPhone): Executed 0 of 0 SUCCESS (0 secs / 0 secs)
NativeScript / 11.4 (11.4; iPhone): Executed 0 of 0 ERROR (0.006 secs / 0 secs)
CONSOLE LOG file:///app/tns_modules/nativescript-unit-test-runner/main-view-model.js:258:24: NSUTR: completeAck
NativeScript / 11.4 (11.4; iPhone) ERROR
Disconnectedclient disconnected from CONNECTED state
NativeScript / 11.4 (11.4; iPhone): Executed 0 of 0 ERROR (0.006 secs / 0 secs)
Package.json 版本:
"nativescript-unit-test-runner": "^0.3.4",
"@types/jasmine": "~2.8.9",
"jasmine-core": "3.2.1",
"karma": "3.0.0",
"karma-jasmine": "1.1.2",
"karma-nativescript-launcher": "0.4.0",
编辑也发生在 Android 上。