Skip to content

nyc on Windows shows 0 coverage  #1381

@osher

Description

@osher

Link to bug demonstration repository

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

(Taken from #1076...)

Expected Behavior

After tests, nyc should show 100% coverage

Observed Behavior

When running tests on Windows, the coverage is 0. Not even after upgrading to nyc@15

C:\ws\nyc-coverage-0-sample>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 |
---------------|----------|----------|----------|----------|-------------------|


C:\ws\nyc-coverage-0-sample>npm ls nyc
nyc-coverage-0@1.0.0 C:\nyc-coverage-0-sample
`-- nyc@14.1.1


C:\ws\nyc-coverage-0-sample>npm i nyc@15 --save-dev
npm WARN nyc-coverage-0@1.0.0 No description                                                                                                                                          bel\helper-module-transforms-1c5a7680 (356ms)
npm WARN nyc-coverage-0@1.0.0 No repository field.

+ nyc@15.1.0
added 65 packages from 26 contributors, removed 29 packages and updated 25 packages in 11.652s

25 packages are looking for funding
  run `npm fund` for details


C:\ws\nyc-coverage-0-sample>nyc mocha


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


  2 passing (7ms)

---------------|---------|----------|---------|---------|-------------------
File           | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
---------------|---------|----------|---------|---------|-------------------
All files      |       0 |        0 |       0 |       0 |
 helloWorld.js |       0 |        0 |       0 |       0 | 1-9
---------------|---------|----------|---------|---------|-------------------

Troubleshooting steps

  • still occurring when I put cache: false in my nyc config

Environment Information

C:\ws\nyc-coverage-0-sample>npx envinfo@latest --preset nyc
'npx' is not recognized as an internal or external command,
operable program or batch file.

C:\ws\nyc-coverage-0-sample>npm i -g envinfo
C:\Program Files (x86)\Nodist\bin\envinfo -> C:\Program Files (x86)\Nodist\bin\node_modules\envinfo\dist\cli.js                                                                       node_modules\.staging
+ envinfo@7.7.3
added 1 package from 1 contributor in 0.862s

C:\ws\nyc-coverage-0-sample>envinfo --preset nyc

  System:
    OS: Windows 10 10.0.19041
    CPU: (8) x64 Intel(R) Core(TM) i7-8550U CPU @ 1.80GHz
    Memory: 2.95 GB / 15.85 GB
  Binaries:
    Node: 12.18.4 - C:\Program Files (x86)\Nodist\bin\node.EXE
    npm: 6.14.6 - C:\Program Files (x86)\Nodist\bin\npm.EXE
  npmPackages:
    nyc: ^15.1.0 => 15.1.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions