Search code examples
mocha.jswebstormistanbul

Coverage in WebStorm with Mocha doesn't work


I followed this guide to get coverage report integrated in WebStorm.

https://www.jetbrains.com/help/webstorm/mocha.html

When I click "Run Mocha test with coverage" the coverage window shows up after running the test. But I don't see any coverage reported. It is not even showing 0%, it is not showing any numbers at all in the Statistics column.

Any help will be appreciated.

Some more background:

  • WebStorm 2017.2.3
  • I'm referring Mocha v3.2.0 in package.json
  • The code is written in ES2015.
  • The mocha Run configuration uses these environment variables

BABEL_ENV=test and these extra mocha options: --compilers js:babel-core/register

Thanks in advance

Further information: when I run with coverage in WebStorm I see this command being output to the console:

/Users/nikolaschou/.nvm/versions/node/v8.1.2/bin/node /Users/nikolaschou/Dev/dsg/bifrostshop/node_modules/nyc/bin/nyc.js --reporter=lcovonly --extension=.ts --extension=.js --exclude=test/unitmocha//.spec. --exclude=test/unitmocha//.test. --report-dir=/private/var/folders/q7/kn0zjzks5dz0q2bx0kpg2yhw0000gn/T/mocha-intellij-coverage- /Users/nikolaschou/Dev/dsg/bifrostshop/node_modules/mocha/bin/_mocha --compilers js:babel-core/register --ui bdd --reporter "/Applications/WebStorm 2.app/Contents/plugins/NodeJS/js/mocha-intellij/lib/mochaIntellijReporter.js" --recursive /Users/nikolaschou/Dev/dsg/bifrostshop/test/unitmocha


Solution

  • Add a file called .nycrc in the project root with these contents:

    { "exclude": [] }
    

    This overrides nyc default config and win is restored.