2

I am trying to get code coverage of my node.js project . I am using mocha and istanbul for that purpose. But i am getting 0 passing Istanbul :No coverage information was collected, exit without writing coverage information Mocha and istanbul are installed locally. Script inside package.json looks like

"scripts": {
    "test": "node_modules/.bin/mocha",
    "test:coverage": "./node_modules/.bin/babel-istanbul cover ./node_modules/.bin/_mocha"
  }

Folder structure looks like -----Project ----node_modules ---test --unit -01test1.tes.js -02test2.test.js

My .istanbul.yml file

verbose: false
instrumentation:
    root: ./node_modules/.bin/istanbul
    default-excludes: true
    excludes: []
    embed-source: false
    variable: __coverage__
    compact: true
    preserve-comments: false
    complete-copy: false
    save-baseline: false
    baseline-file: ./coverage/coverage-baseline.json
reporting:
    print: summary
    reports:
        - lcov
    dir: ./coverage
    watermarks:
        statements: [50, 80]
        lines: [50, 80]
        functions: [50, 80]
        branches: [50, 80]
hooks:
    hook-run-in-context: false
    post-require-hook: null

I am running coomand

npm run test:coverage

in terminal(mac OSX). I am fairly new to this so any input is very much welcome. Please help me with it , i have already spent whole day over this.

user2991413
  • 521
  • 2
  • 9
  • 26

2 Answers2

0

Could you try default-excludes: false as it seems your tests are under node_modules?

SGD
  • 1,676
  • 14
  • 18
0

I answered here

I used babel-node module and it works form me. I am using below command.

babel-node node_modules/.bin/babel-istanbul cover _mocha -- --recursive tests/test.*.js --exit
A_J
  • 1,635
  • 1
  • 18
  • 31