Nx: Jest coverage report does not print to console with 7.8.5

Created on 10 May 2019  路  3Comments  路  Source: nrwl/nx

Prerequisites

  • [x] I am running the latest version
  • [x] I checked the documentation and found no answer
  • [x] I checked to make sure that this issue has not already been filed
  • [x] I'm reporting the issue to the correct repository (not related to Angular, AngularCLI or any dependency)

Expected Behavior

ng test runs the test suites and prints the code coverage report to the console.

Current Behavior

ng test runs the test suites.

Failure Information (for bugs)

On a newly-created workspace, neither ng test nor ng test --code-coverage prints out the code coverage report to the console. Further, Jest commands cannot be appended to ng test to remediate, nor can ng test be easily substituted for jest.

Additionally, adding codeCoverage: true to the app's test options configuration in the angular.json does not resolve the issue. The issue also persists when adding collectCoverageFrom: ['**/*.{js,jsx}', '!**/node_modules/**', '!**/vendor/**'] to the jest.config.js module.exports.

Steps to Reproduce

Please provide detailed steps for reproducing the issue.

  1. Create a new workspace (yarn create nx-workspace myworkspace);
  2. Move into the new workspace (cd myworkspace);
  3. Run the tests (ng test);
  4. Notice that the tests run successfully and the coverage directory is created.

Context

I used the instructions listed on the Getting Started page. Attempted with workspaces that included Angular, React, and Angular and React applications.

To confirm that this wasn't an issue with the latest version of Jest, I followed Jest's Getting Started instructions and ran jest --coverage, which successfully printed the code coverage report.

Failure Logs

N/A

Other

Thanks, in advance, for your help :)

Most helpful comment

It's not enabled by default but you can have it print to console if you add 'text' to the root jest.config.js's coverageReporters option. Feel free to make the change in your repo.

Closing this issue for now. Please reopen if you have any other issues.

All 3 comments

It's not enabled by default but you can have it print to console if you add 'text' to the root jest.config.js's coverageReporters option. Feel free to make the change in your repo.

Closing this issue for now. Please reopen if you have any other issues.

You're a hero. Thanks, @FrozenPandaz!

It's not enabled by default but you can have it print to console if you add 'text' to the root jest.config.js's coverageReporters option. Feel free to make the change in your repo.

Closing this issue for now. Please reopen if you have any other issues.

Hi @FrozenPandaz ,

I have a nx project with Angular + Jest, how do I obtain a global (unique) coverage summaries? I'm currently using the Jest's 'text-summary' as coverageReporters but it promps as many abstracts as libraries... Any idea?

Thanks in advance.
Regards,
Romain.

Was this page helpful?
0 / 5 - 0 ratings