Skip to content
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

Coverage empty when calling test script via yarn #1221

Closed
pdfowler opened this issue Nov 14, 2019 · 3 comments
Closed

Coverage empty when calling test script via yarn #1221

pdfowler opened this issue Nov 14, 2019 · 3 comments

Comments

@pdfowler
Copy link

pdfowler commented Nov 14, 2019

Repro Repo

Sorry - Private repo. Trying to gen min repro case

Configuration:

In my package.json file, I have the following lines in my scripts node:

scripts: { ...
    "test": "cross-env NODE_ENV=test env-path -p test/.env mocha \"test/**/*.test.js\" --recursive --exit",
    "test:coverage": "cross-env NODE_ENV=test nyc --reporter=lcov yarn run test",
... },

Expected Behavior

Running yarn run test:coverage should populate the lcov report at ./coverage/lcov-report/index.html

Observed Behavior

The lcov report is completely empty

Troubleshooting steps

When my test:coverage script is changed to have the contents of the test script directly in the test:coverage script, my lcov report is correctly generated

"test:coverage": "cross-env NODE_ENV=test ESM_DISABLE_CACHE=1 nyc --cache=false --reporter=lcov env-path -p test/.env mocha \"test/**/*.test.js\" --recursive --exit",

Environment Information

  System:
    OS: macOS Mojave 10.14.6
    CPU: (12) x64 Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz
    Memory: 402.93 MB / 16.00 GB
  Binaries:
    Node: 10.16.3 - ~/.nvm/versions/node/v10.16.3/bin/node
    Yarn: 1.19.1 - ~/.yarn/bin/yarn
    npm: 5.1.0 - /usr/local/bin/npm
  npmPackages:
    @babel/core: ^7.0.0 => 7.1.6 
    @babel/plugin-proposal-class-properties: ^7.0.0 => 7.1.0 
    @babel/plugin-proposal-decorators: ^7.2.0 => 7.2.0 
    @babel/plugin-proposal-do-expressions: ^7.0.0 => 7.0.0 
    @babel/plugin-proposal-export-default-from: ^7.0.0 => 7.0.0 
    @babel/plugin-proposal-export-namespace-from: ^7.0.0 => 7.0.0 
    @babel/plugin-proposal-function-bind: ^7.0.0 => 7.0.0 
    @babel/plugin-proposal-function-sent: ^7.0.0 => 7.1.0 
    @babel/plugin-proposal-json-strings: ^7.0.0 => 7.0.0 
    @babel/plugin-proposal-logical-assignment-operators: ^7.0.0 => 7.0.0 
    @babel/plugin-proposal-nullish-coalescing-operator: ^7.0.0 => 7.0.0 
    @babel/plugin-proposal-numeric-separator: ^7.0.0 => 7.0.0 
    @babel/plugin-proposal-optional-chaining: ^7.0.0 => 7.0.0 
    @babel/plugin-proposal-pipeline-operator: ^7.0.0 => 7.0.0 
    @babel/plugin-proposal-throw-expressions: ^7.0.0 => 7.0.0 
    @babel/plugin-syntax-dynamic-import: ^7.0.0 => 7.0.0 
    @babel/plugin-syntax-import-meta: ^7.0.0 => 7.0.0 
    @babel/plugin-transform-runtime: ^7.1.0 => 7.1.0 
    @babel/polyfill: ^7.0.0 => 7.0.0 
    @babel/preset-env: ^7.2.0 => 7.2.0 
    @babel/preset-react: ^7.0.0 => 7.0.0 
    @babel/register: ^7.0.0 => 7.0.0 
    @babel/runtime: ^7.1.5 => 7.1.5 
    @types/babel-core: ^6.25.0 => 6.25.3 
    @types/babel__core: ^7.0.4 => 7.0.4 
    babel-eslint: ^10.0.1 => 10.0.1 
    babel-loader: ^8.0.0 => 8.0.4 
    babel-plugin-istanbul: ^5.1.0 => 5.1.0 
    babel-plugin-root-import: ^6.1.0 => 6.1.0 
    babel-plugin-system-import-transformer: ^3.1.0 => 3.1.0 
    eslint-import-resolver-babel-plugin-root-import: ^1.1.1 => 1.1.1 
    eslint-plugin-babel: ^5.3.0 => 5.3.0 
    nyc: ^14.1.1 => 14.1.1 

Other Notes:

Since last running my coverage script (I know, I know):

  • I recently upgraded from yarn@~1.09 (?) to yarn@1.19
  • I upgraded node from 8.x to 10.x
  • Observed originally with nyc@13.1.0. Updated to nyc@14 to no effect.
@pdfowler pdfowler changed the title Coverage empty when calling test script running yarn Coverage empty when calling test script via yarn Nov 14, 2019
@coreyfarrell
Copy link
Member

Please test with the beta release of nyc 15. nyc 15 makes use of a new technique for wrapping child processes which fixes known issues with yarn. Be sure to upgrade babel-plugin-istanbul to the beta release of 6 at the same time.

@pdfowler
Copy link
Author

That did the trick!

yarn add nyc@next babel-plugin-istanbul@next`;
yarn run test

Result: Successfully generated coverage report, followed by recalling how far we still have to go on coverage. At least we've got most of our critical logic covered!

@coreyfarrell
Copy link
Member

Thanks for reporting back, I'm going to close this as no further code changes are expected. You can click Subscribe on #1104 to get updates about the progress for the final release of nyc@15.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants