Skip to content

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

Closed
@psamusev

Description

@psamusev

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions