angular-library-starter icon indicating copy to clipboard operation
angular-library-starter copied to clipboard

Jest coverage isn't tracked when tests are added (sometimes)

Open benjamincharity opened this issue 7 years ago • 0 comments

  • I'm submitting a ... [x] bug report

Possibly a Jest issue, but adding here since I haven't seen this issue outside of this starter library.

  • What is the current behavior?

Add some files and run Jest to output the coverage result:

no test or empty test

a) The regex directory seems to work fine with test content b) notice the file dispatch-events.ts which correctly has 0 coverage at this point

Add some tests for dispatch-events.ts and this is the output:

with test

Notice the dispatch-events.ts file is completely gone from coverage reporting.

  • If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem
  1. git clone https://github.com/GetTerminus/ngx-tools
  2. git checkout ae7d9f23002dac08e5801ed9fecf7ba5d5835282
  3. yarn install (or npm)
  4. yarn run lib:test (or npm)

I'm thinking maybe it has something to do with extension directories? If I clone a fresh angular-library-starter, delete the examples dir and add a simple test inside my-lib/src the coverage is reported.

  • What is the expected behavior?

The coverage output should include all files that are matched by the glob in jest.library.config.json which is

  "collectCoverageFrom": [
    "src/@terminus/ngx-tools/**/!(public-api).ts",
    "!src/@terminus/ngx-tools/testing/src/mocks/**/*",
    "!src/@terminus/ngx-tools/keycodes/**/*"
  ]
  • What is the motivation / use case for changing the behavior?

Correct coverage

  • Please tell us about your environment:
Angular CLI: 1.6.7
Node: 8.4.0
OS: darwin x64
Angular: 5.0.2
... animations, common, compiler, compiler-cli, core, forms
... http, platform-browser, platform-browser-dynamic
... platform-server, router
@angular-devkit/build-optimizer: 0.0.32
@ngtools/webpack: 1.8.2
typescript: 2.7.1
webpack-dev-middleware: 1.12.0
webpack-dev-server: 2.9.4
webpack-dll-bundles-plugin: 1.0.0-beta.5
webpack-merge: 4.1.0
webpack: 3.8.1

benjamincharity avatar Feb 07 '18 13:02 benjamincharity