javascript - I am getting 0 % coverage 0 SLOC in mocha code coverage using blanket -


i trying code coverage in mocha js test. using blanket , getting 0 % coverage 0 sloc why not understanding. package.json

{   "name": "basics",   "version": "1.0.0",   "description": "",   "main": "index.js",   "scripts": {     "test": "mocha && mocha test --require blanket --reporter html-cov > coverage.html"   },   "author": "",   "license": "mit",   "devdependencies": {     "chai": "~2.2.0",     "mocha": "~2.2.4",     "blanket": "~1.1.6",    },   "config": {     "blanket": {       "pattern": ["index.js"],       "data-cover-never": "node_modules"     }   } } 

and index.js

exports.sanitize = function(word){       return word.tolowercase().replace(/-/g, ' '); }  exports.testtostring = function(){       return word.tolowercase().replace(/-/g, ' '); } 

and indexspec.js under test folder

var chai = require('chai'); var expect = require('chai').expect; var word = require('../index.js');  describe ('sanitize', function(){     it('string matching ', function(){          var inputword = 'hello world';         var outputword = word.sanitize(inputword);         expect(outputword).to.equal('hello world');         expect(outputword).to.not.equal('hello world');         expect(outputword).to.be.a('string');         expect(outputword).not.to.be.a('number');      });      it('checke hyphen ', function(){         var inputword = 'hello-world';         var outputword = word.sanitize(inputword);         expect(outputword).to.equal('hello world');     }); } ) 

paul right. there no point in using buggy library. steps making code work istanbul:

  1. install istanbul globally npm install -g istanbul
  2. change script section in package.json
  "scripts": {     "test": "mocha",     "coverage": "istanbul cover node_modules/mocha/bin/_mocha -- -r spec"   }, 
  1. run test typing npm test

  2. generage coverage report: npm run coverage

coverage report available in coverage/lcov-report/index.html


Comments

Popular posts from this blog

shopping cart - Page redirect not working PHP -

php - How to modify a menu to show sub-menus -

python - Installing PyDev in eclipse is failed -