vendredi 24 avril 2015

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

I am trying to get the code coverage in MOCHA JS test. I am using the blanket and the but I am getting 0 % coverage 0 SLOC why I am not understanding. my package.json is

{
  "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 is

exports.sanitize = function(word){


    return word.toLowerCase().replace(/-/g, ' ');
}

exports.testToString = function(){


    return word.toLowerCase().replace(/-/g, ' ');
}

and indexSpec.js which is under test folder is

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');
    });
} )

Aucun commentaire:

Enregistrer un commentaire