Skip to content

Coverage is undefined if sourceRoot is not set #23591

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
1 of 15 tasks
bgotink opened this issue Jul 18, 2022 · 1 comment · Fixed by #23592
Closed
1 of 15 tasks

Coverage is undefined if sourceRoot is not set #23591

bgotink opened this issue Jul 18, 2022 · 1 comment · Fixed by #23592
Assignees

Comments

@bgotink
Copy link
Contributor

bgotink commented Jul 18, 2022

🐞 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?

@alan-agius4 alan-agius4 self-assigned this Jul 18, 2022
alan-agius4 added a commit to alan-agius4/angular-cli that referenced this issue Jul 18, 2022
…sourceRoot is missing during coverage

With this change we fallback to use the projectRoot when the sourceRoot is missing for files to be included in coverge.

Closes: angular#23591
alan-agius4 added a commit to alan-agius4/angular-cli that referenced this issue Jul 18, 2022
…sourceRoot is missing during coverage

With this change we fallback to use the projectRoot when the sourceRoot is missing for files to be included in coverage.

Closes: angular#23591
clydin pushed a commit that referenced this issue Jul 18, 2022
…sourceRoot is missing during coverage

With this change we fallback to use the projectRoot when the sourceRoot is missing for files to be included in coverage.

Closes: #23591
clydin pushed a commit that referenced this issue Jul 18, 2022
…sourceRoot is missing during coverage

With this change we fallback to use the projectRoot when the sourceRoot is missing for files to be included in coverage.

Closes: #23591
(cherry picked from commit d8cfe8b)
clydin pushed a commit that referenced this issue Jul 18, 2022
…sourceRoot is missing during coverage

With this change we fallback to use the projectRoot when the sourceRoot is missing for files to be included in coverage.

Closes: #23591
(cherry picked from commit d8cfe8b)
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Aug 18, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
2 participants