Skip to content

Coverage is undefined if sourceRoot is not set #23591

Closed
@bgotink

Description

@bgotink

🐞 Bug report

Command (mark with an x)

  • new
  • build
  • serve
  • test
  • e2e
  • generate
  • add
  • update
  • lint
  • extract-i18n
  • run
  • config
  • help
  • version
  • doc

Is this a regression?

Yes, coverage was generated properly even with sourceRoot unset in angular 12.

Description

The @angular-devkit/build-angular builder fails to generate coverage if sourceRoot is not set. There's no error or warning linking this to the missing sourceRoot.

Possibly related to #22161, though the lack of a reproduction in that issue makes it unclear if it really is the same.

🔬 Minimal Reproduction

npx --package @angular/cli@latest ng new repro --defaults
cd repro
# remove the sourceRoot, e.g. via jq
jq 'del(.projects.repro.sourceRoot)' angular.json | sponge angular.json

# now run tests
npx ng test --code-coverage --watch false

🔥 Exception or Error


✔ Browser application bundle generation complete.
18 07 2022 14:34:09.375:INFO [karma-server]: Karma v6.3.20 server started at http://localhost:9876/
18 07 2022 14:34:09.376:INFO [launcher]: Launching browsers Chrome with concurrency unlimited
18 07 2022 14:34:09.380:INFO [launcher]: Starting browser Chrome
18 07 2022 14:34:11.139:INFO [Chrome 103.0.5060.114 (Mac OS 10.15.7)]: Connected on socket GbDlEOfCDPMnbVHSAAAB with id 7822168
Chrome 103.0.5060.114 (Mac OS 10.15.7): Executed 3 of 3 SUCCESS (0.098 secs / 0.09 secs)
TOTAL: 3 SUCCESS

=============================== Coverage summary ===============================
Statements   : Unknown% ( 0/0 )
Branches     : Unknown% ( 0/0 )
Functions    : Unknown% ( 0/0 )
Lines        : Unknown% ( 0/0 )
================================================================================
✨  Done in 9.73s.

🌍 Your Environment


Angular CLI: 14.0.6
Node: 16.15.0
Package Manager: yarn 1.22.15 
OS: darwin x64

Angular: 14.0.6
... animations, cli, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, router

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1400.6
@angular-devkit/build-angular   14.0.6
@angular-devkit/core            14.0.6
@angular-devkit/schematics      14.0.6
@schematics/angular             14.0.6
rxjs                            7.5.6
typescript                      4.7.4

Anything else relevant?

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions