5

I am trying to run code coverage for my Node project, but for some reason it's not working. I am using chai+mocha+istanbul and have also tried with nyc. My code has both ES5 as well as ES6 components, and I am using compiler tags for this. The tests run fine, but the code coverage shows nothing.

11 passing (15ms)
    ----------|----------|----------|----------|----------|----------------|
    File      |  % Stmts | % Branch |  % Funcs |  % Lines |Uncovered Lines |
    ----------|----------|----------|----------|----------|----------------|
    All files |  Unknown |  Unknown |  Unknown |  Unknown |                |
    ----------|----------|----------|----------|----------|----------------|

Relevant section of my package.json:

"test": "mocha test/app.test.js --compilers js:babel-core/register",
"test:cover": "nyc npm t",
"coverage": "babel-node ./node_modules/.bin/isparta cover mocha -- --compilers js:babel-register",
"cover": "cross-env NODE_ENV=test nyc --reporter=lcov --reporter=text mocha --compilers js:babel-register test/*.js"

As you can probably figure out, I have tried different combinations and alternatives, but nothing seems to be working for me.

Relevant section of the dev dependencies:

    "babel-cli": "^6.16.0",
    "babel-core": "^6.26.0",
    "babel-loader": "^7.1.2",
    "babel-preset-es2015": "^6.24.1",
    "babel-register": "6.26.0",
    "chai": "^4.1.2",
    "cross-env": "5.1.3",
    "isparta": "^4.0.0",
    "istanbul": "0.4.5",
    "mocha": "^5.0.0",
    "nyc": "10.0.0",

Please do help or suggest where I can look for for more information.

Grant Miller
  • 27,532
  • 16
  • 147
  • 165
Why
  • 626
  • 11
  • 29

0 Answers0