shlomiassaf / angular-library-starter

Your last library starter. A complete, @angular grade, library starter
MIT License
44 stars 12 forks source link

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

Open benjamincharity opened 6 years ago

benjamincharity commented 6 years ago

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

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.

  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.

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/**/*"
  ]

Correct coverage

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