ng test --code-coverage 不打印覆盖细节 [英] ng test --code-coverage not printing coverage details

查看:30
本文介绍了ng test --code-coverage 不打印覆盖细节的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我使用 ng test --code-coverage 运行测试时,我发现代码覆盖率未知,不确定可能出了什么问题.感谢这里的任何帮助.

When I run the tests using ng test --code-coverage I get the code coverage as unknown, not sure what might be going wrong. Any help here is appreciated.

> ng test --code-coverage

 10% building modules 1/1 modules 0 active26 06 2018 11:00:51.088:WARN [karma]: No captured browser, open http://localhost:9876/
26 06 2018 11:00:51.095:INFO [karma]: Karma v2.0.0 server started at http://0.0.0.0:9876/
26 06 2018 11:00:51.095:INFO [launcher]: Launching browser Chrome with unlimited concurrency
26 06 2018 11:00:51.100:INFO [launcher]: Starting browser Chrome
26 06 2018 11:01:48.404:WARN [karma]: No captured browser, open http://localhost:9876/    
26 06 2018 11:01:48.665:INFO [Chrome 67.0.3396 (Mac OS X 10.11.6)]: Connected on socket UhrUQZiU8ZuG8qRwAAAA with id 31579746
Chrome 67.0.3396 (Mac OS X 10.11.6): Executed 1151 of 2149 (skipped 843) SUCCESS (0 secs / 0 secs)
26 06 2018 11:07:31.910:WARN [Chrome 67.0.3396 (Mac OS X 10.11.6)]: Disconnected (1 times), because no message in 10000 ms.
Chrome 67.0.3396 (Mac OS X 10.11.6) ERROR
Chrome 67.0.3396 (Mac OS X 10.11.6) ERROR
  Disconnected, because no message in 10000 ms.
Chrome 67.0.3396 (Mac OS X 10.11.6): Executed 1151 of 2149 (skipped 843) DISCONNECTED (5 mins 31.686 secs / 0 secs)
Chrome 67.0.3396 (Mac OS X 10.11.6) ERROR
Chrome 67.0.3396 (Mac OS X 10.11.6): Executed 1151 of 2149 (skipped 843) DISCONNECTED (5 mins 31.686 secs / 0 secs)

=============================== Coverage summary ===============================
Statements   : Unknown% ( 0/0 )
Branches     : Unknown% ( 0/0 )
Functions    : Unknown% ( 0/0 )
Lines        : Unknown% ( 0/0 )
Chrome 67.0.3396 (Mac OS X 10.11.6): Executed 1295 of 2149 (skipped 854) DISCONNECTED (6 mins 49.413 secs / 0 secs)

推荐答案

我遇到了同样的问题并通过确保 "sourceRoot" 属性在 angular.json 中修复它 设置为项目源文件的根文件夹.

I ran into the same problem and fixed it by making sure the "sourceRoot" property in the angular.json is set to the root folder for the project's source files.

ng cli 使用sourceRoot"中的文件来计算覆盖率.

The ng cli uses the files in "sourceRoot" to compute coverage.

它似乎没有用 sourceRoot 做任何其他测试,所以测试运行并通过,但覆盖率不起作用.

It doesn't seem to do anything else with sourceRoot for tests, so the tests run and pass, but coverage doesn't work.

这篇关于ng test --code-coverage 不打印覆盖细节的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆