Windows shows 0 coverage when runing with npm/yarn
See original GitHub issueLink 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:
- Created 4 years ago
- Comments:9 (2 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

@coreyfarrell My use case is that after upgrading to
v14the reporter doesn’t print any files results. After investigating I found thatexclude-after-remapwastrueby 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
nycoptions documented somewhere?PS: In using a
Typescriptproject.im having the same issue, regardless to npm or yarn