ng test --code-coverage not printing coverage details
Asked Answered
M

1

2

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)
Martres answered 26/6, 2018 at 18:18 Comment(3)
Go to ./coverage folder at your project root. You can then open ./coverage/index.html to see the coverage report.Flinch
coverage/index.html also shows coverage as unknown..Martres
I am facing the same have you found any solutionAerification
D
3

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.

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

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

Delectation answered 20/7, 2020 at 19:7 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.