Skip to content

ng test --code-coverage doesn't include files outside of src folder #12474

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
psamusev opened this issue Oct 4, 2018 · 3 comments
Closed

ng test --code-coverage doesn't include files outside of src folder #12474

psamusev opened this issue Oct 4, 2018 · 3 comments

Comments

@psamusev
Copy link
Contributor

psamusev commented Oct 4, 2018

Bug Report or Feature Request (mark with an x)

- [x] bug report -> please search issues before submitting
- [ ] feature request

Command (mark with an x)

- [ ] new
- [ ] build
- [ ] serve
- [x] test
- [ ] e2e
- [ ] generate
- [ ] add
- [ ] update
- [ ] lint
- [ ] xi18n
- [ ] run
- [ ] config
- [ ] help
- [ ] version
- [ ] doc

Versions

node v8.9.4
npm v6.4.1
Mac OS Mojave
Angular CLI: 6.2.4
Angular: 6.1.9

Repro steps

  1. ng new test-app
  2. create packages/test-package outside of src folder
  3. add there simple test.component.ts and test.component.spec.ts
  4. Modify test.ts file and add context of 'packages directory
    replace
const context = require.context('./', true, /\.spec\.ts$/);
context.keys().map(context1);

with

const context1 = require.context('../packages', true, /\.spec\.ts$/);
const context2 = require.context('./', true, /\.spec\.ts$/);

context1.keys().map(context1);
context2.keys().map(context2);
  1. Add "../packages/**/*.spec.ts", to tsconfig.spec.json in "include" section

  2. ng test --code-coverage and open coverage/index.html

Description

Files from packages directory don't include in final coverage report

Desired functionality

All files despite on their location should be presented in final coverage report

@alan-agius4
Copy link
Collaborator

This is actually by design, Only files under sourceRoot are listed in the code coverage report. Anything which is not under sourceRoot is considered as external.

#11934

@Pringels
Copy link

Pringels commented Nov 1, 2018

It would be great if we could supply an optional list of external directories to include. (perhaps in angular.json?)

That commit completely broke coverage reporting in my team's mono-repo setup :(

@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 Sep 8, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants