我正在基于以下示例项目在 ionic3 项目中实施单元测试:https ://github.com/ionic-team/ionic-unit-testing-example 。
它工作正常,但我有一些问题:
我可以看到编译错误(对于 jasmine),而这些错误并不能阻止运行测试
karma start ./test-config/karma.conf.js webpack: Compiled successfully. webpack: Compiling... 17 03 2018 15:53:18.403:WARN [karma]: No captured browser, open http://localhost:9876/ ERROR in ./src/pages/test/test.spec.ts [tsl] ERROR in /home/app-path/src/pages/test/test.spec.ts(11,1) TS2304: Cannot find name 'describe'. ERROR in ./src/pages/test/test.spec.ts [tsl] ERROR in /home/app-path/src/pages/test/test.spec.ts(17,3) TS2304: Cannot find name 'beforeEach'. ERROR in ./src/pages/test/test.spec.ts [tsl] ERROR in /home/app-path/src/pages/test/test.spec.ts(40,39) TS2304: Cannot find name 'expect'. ERROR in ./src/pages/test/test.spec.ts [tsl] ERROR in /home/app-path/src/pages/test/test.spec.ts(42,3) TS2304: Cannot find name 'it'. ... webpack: Failed to compile. 17 03 2018 15:53:18.422:INFO [karma]: Karma v1.7.1 server started at http://0.0.0.0:9876/ 17 03 2018 15:53:18.422:INFO [launcher]: Launching browser Chrome with unlimited concurrency 17 03 2018 15:53:18.748:INFO [launcher]: Starting browser Chrome 17 03 2018 15:53:20.153:INFO [Chrome 57.0.2987 (Linux 0.0.0)]: Connected on socket py7H3olXgBzYBE2DAAAA with id 24040166 Chrome 57.0.2987 (Linux 0.0.0): Executed 8 of 8 SUCCESS (2.716 secs / 0 secs)
即使我
kjhtml
配置了记者,我也无法在 karma 启动的浏览器中显示结果。请参阅https://github.com/ionic-team/ionic-unit-testing-example/blob/master/test-config/karma.conf.js#L52。注意我添加了progress
记者,它工作正常:reporters: ['progress', 'kjhtml'],
谢谢你的帮助!