question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Windows shows 0 coverage when runing with npm/yarn

See original GitHub issue

Link to bug demonstration repository

https://github.com/mariszin/nyc-coverage-0-sample

Expected Behavior

After tests, nyc should show 100% coverage

Observed Behavior

When running tests on Windows, the coverage is 0

$ yarn test
yarn run v1.12.1
$ cross-env NODE_ENV=test nyc mocha


  HelloWorld
    √ should return hello world with no arguments
    √ should return passed argument


  2 passing (6ms)

---------------|----------|----------|----------|----------|-------------------|
File           |  % Stmts | % Branch |  % Funcs |  % Lines | Uncovered Line #s |
---------------|----------|----------|----------|----------|-------------------|
All files      |        0 |        0 |        0 |        0 |                   |
 helloWorld.js |        0 |        0 |        0 |        0 |         1,2,3,5,9 |
---------------|----------|----------|----------|----------|-------------------|
Done in 4.09s.

When running same repo under Windows Ubuntu shell, the coverage shows correctly at 100%

$ cross-env NODE_ENV=test nyc mocha


  HelloWorld
    ✓ should return hello world with no arguments
    ✓ should return passed argument


  2 passing (8ms)

---------------|----------|----------|----------|----------|-------------------|
File           |  % Stmts | % Branch |  % Funcs |  % Lines | Uncovered Line #s |
---------------|----------|----------|----------|----------|-------------------|
All files      |      100 |      100 |      100 |      100 |                   |
 helloWorld.js |      100 |      100 |      100 |      100 |                   |
---------------|----------|----------|----------|----------|-------------------|
Done in 2.17s.

Environment Information

In Windows Git Bash

  System:
    OS: Windows 10
    CPU: (12) x64 Intel(R) Core(TM) i7-8700K CPU @ 3.70GHz
    Memory: 17.54 GB / 31.92 GB
  Binaries:
    Node: 10.15.3 - C:\nodejs\node.EXE
    Yarn: 1.12.1 - C:\Program Files (x86)\Yarn\bin\yarn.CMD
    npm: 6.4.1 - C:\nodejs\npm.CMD
  npmPackages:
    nyc: ^14.0.0 => 14.0.0

In Windows Ubuntu shell

  System:
    OS: Linux 4.4 Ubuntu 18.04.1 LTS (Bionic Beaver)
    CPU: (12) x64 Intel(R) Core(TM) i7-8700K CPU @ 3.70GHz
    Memory: 17.55 GB / 31.92 GB
  Binaries:
    Node: 10.15.3 - /usr/bin/node
    Yarn: 1.15.2 - /usr/bin/yarn
    npm: 6.4.1 - /usr/bin/npm
  npmPackages:
    nyc: ^14.0.0 => 14.0.0

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:9 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
JimiCcommented, Apr 23, 2019

@coreyfarrell My use case is that after upgrading to v14 the reporter doesn’t print any files results. After investigating I found that exclude-after-remap was true by default and thus was excluding all results. Maybe it’s a different issue but the symptoms looked the same. I preferred to post here instead of opening another issue not being sure if my case is irrelevant to this.

Are the nyc options documented somewhere?

PS: In using a Typescript project.

0reactions
oshercommented, Jan 14, 2021

im having the same issue, regardless to npm or yarn

Read more comments on GitHub >

github_iconTop Results From Across the Web

Jest finds tests but doesn't collect coverage - Stack Overflow
The quick fix I said in my comment, using --watchAll instead, eg: react-scripts test --coverage --watchAll . Just for future reference, ...
Read more >
Use Azure Pipelines to build and publish a Node.js package
Build, deploy, and test JavaScript and Node.js apps with Azure Pipelines. ... An ability to run pipelines on Microsoft-hosted agents.
Read more >
Jest CLI Options
If you run Jest via yarn test , you can pass the command line ... a test coverage for the source files, no...
Read more >
Running Tests | Create React App
When you run npm test , Jest will launch in watch mode *. Every time you save a file, it will re-run the...
Read more >
@cypress/code-coverage | Yarn - Package Manager
owner cypress-io1.6mMIT3.10.0 vulns 0 vulnerabilities. Saves the code coverage collected during Cypress tests ... npm install -D @cypress/code-coverage.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found