nyc: Windows causes coverage to be 0%

Link to bug demonstration repository.

https://github.com/michaelKurowski/lokim2/tree/nyc-issue-branch

Expected Behavior

  • npm i in the main directory
  • gulp prepareDev
  • put some mongodb credentials into src/server/config.json (mlab provides free ones, I can also send credentials to a free instance created there)
  • gulp serverTestCoverage
  • I should see a table with files covered with realistic results. Something like that: https://gist.github.com/michaelKurowski/09e493010cfe6ac5faa0c823f4605845

Observed Behavior

Everything works flawlessly on Linux, but on Windows I get a corrupted report: https://gist.github.com/michaelKurowski/a562595264d935b22d57f79daeaeefb6

Forensic Information

Operating System: Observed on Windows 7 and 10 Environment Information: https://gist.github.com/michaelKurowski/01980c68ac8916605b36292f33f77504

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 16 (5 by maintainers)

Most upvoted comments

Issue has been solved. I’ve had to run mocha directly in gulp serverTest instead of using npx

@calebcartwright OP has experienced the issue with nyc@11. If you are only experiencing the issue with nyc@14 then it’s definitely a different issue, even if it has some of the same symptoms.

@calebcartwright you are experiencing a different issue than OP. Your issue (I suspect) is that nyc@14 enables --exclude-after-remap which means that we look at the source-maps to determine the original filename and process include, exclude, and extension matching to determine what should/shouldn’t be reported.

Everybody: please do not comment here unless you are experiencing the exact issue @michaelKurowski reported - flawless coverage under Linux but not Windows. For everything else please post a new issue including all required information.

Having the same issue here. On Win10 w/ Git Bash, I get:

------------------|----------|----------|----------|----------|-------------------|
File              |  % Stmts | % Branch |  % Funcs |  % Lines | Uncovered Line #s |
------------------|----------|----------|----------|----------|-------------------|
All files         |        0 |        0 |        0 |        0 |                   |
 models           |        0 |        0 |        0 |        0 |                   |
  club.js         |        0 |      100 |        0 |        0 |       2,3,9,10,12 |
  competition.js  |        0 |      100 |        0 |        0 |       2,3,9,10,12 |
  group.js        |        0 |      100 |        0 |        0 |       2,3,9,10,12 |
  index.js        |        0 |        0 |        0 |        0 |... 29,30,34,35,37 |
  person.js       |        0 |      100 |        0 |        0 |   2,3,11,12,13,15 |
  result.js       |        0 |      100 |        0 |        0 |... 22,23,24,25,27 |
  stage.js        |        0 |      100 |        0 |        0 |   2,3,11,12,13,15 |
  user.js         |        0 |        0 |        0 |        0 |... 25,26,27,29,33 |
 routes           |        0 |        0 |        0 |        0 |                   |
  auth.js         |        0 |      100 |        0 |        0 |... 14,17,18,19,22 |
  competitions.js |        0 |        0 |        0 |        0 |... 3,90,93,96,100 |
  index.js        |        0 |      100 |      100 |        0 |... 10,11,12,13,15 |
  stages.js       |        0 |        0 |        0 |        0 |... 49,55,58,61,65 |
 routes/admin     |        0 |        0 |        0 |        0 |                   |
  competitions.js |        0 |        0 |        0 |        0 |... 48,49,52,53,59 |
  index.js        |        0 |      100 |      100 |        0 |       1,2,4,5,6,8 |
  upload.js       |        0 |        0 |        0 |        0 |... 22,126,127,137 |
  users.js        |        0 |        0 |        0 |        0 |... 30,31,33,34,40 |
------------------|----------|----------|----------|----------|-------------------|

When I run the same command on Ubuntu Bash:

------------------|----------|----------|----------|----------|-------------------|
File              |  % Stmts | % Branch |  % Funcs |  % Lines | Uncovered Line #s |
------------------|----------|----------|----------|----------|-------------------|
All files         |    68.72 |    28.57 |    38.81 |    69.01 |                   |
 models           |    89.71 |    54.55 |    80.95 |    89.71 |                   |
  club.js         |      100 |      100 |      100 |      100 |                   |
  competition.js  |      100 |      100 |      100 |      100 |                   |
  group.js        |      100 |      100 |      100 |      100 |                   |
  index.js        |       95 |    66.67 |      100 |       95 |                13 |
  person.js       |      100 |      100 |      100 |      100 |                   |
  result.js       |      100 |      100 |      100 |      100 |                   |
  stage.js        |      100 |      100 |      100 |      100 |                   |
  user.js         |    53.85 |        0 |    33.33 |    53.85 | 18,20,25,26,27,29 |
 routes           |    76.92 |    66.67 |    42.86 |    77.92 |                   |
  auth.js         |    63.64 |      100 |        0 |    63.64 |        9,14,18,19 |
  competitions.js |    90.63 |      100 |       75 |    90.63 |          53,90,96 |
  index.js        |      100 |      100 |      100 |      100 |                   |
  stages.js       |    54.17 |        0 |        0 |    56.52 |... 36,49,55,58,61 |
 routes/admin     |    47.42 |        0 |        0 |    47.42 |                   |
  competitions.js |    42.31 |        0 |        0 |    42.31 |... 47,48,49,52,53 |
  index.js        |      100 |      100 |      100 |      100 |                   |
  upload.js       |     41.3 |        0 |        0 |     41.3 |... 10,120,122,127 |
  users.js        |    52.63 |        0 |        0 |    52.63 |... 23,30,31,33,34 |
------------------|----------|----------|----------|----------|-------------------|

node -v => v10.15.3 Using only yarn to run tests (yarn test). Relevant package.json :

...
  "devDependencies": {
    "chai": "^4.2.0",
    "chai-http": "^4.2.1",
    "cross-env": "^5.2.0",
    "mocha": "^6.1.3",
    "nodemon": "^1.18.10",
    "nyc": "^14.0.0"
  },
  "nyc": {
    "all": true,
    "include": [
      "models/**/*.js",
      "routes/**/*.js"
    ]
  }
...