lundi 1 août 2016

Mocha & Istanbul cannot get coverage information

When I run the following command to generate the coverage information, nothing was generated.

I've installed istanbul using npm globally and the mocha test passed with no error but there's still no coverage information.

Does anyone know how to get the coverage information from mocha & Chai tests?

Is there any additional configuration needed?

c:\mymocha>istanbul cover ./node_modules/mocha/bin/_mocha -- -R spec


  Unit test demo
    Coverage demo
      √ greater than 0 should be true


  1 passing (11ms)

No coverage information was collected, exit without writing coverage information

Test.ts

import * as chai from "chai";
let assert = chai.assert;

function testfunc(n:number):boolean{
    if (n>0){
        return true;
    }else{
        return false;
    }
}

describe('Unit test demo', function() {
  describe('Coverage demo', function() {
    it('greater than 0 should be true', function() {
        assert.isTrue(testfunc(10));
    });
  });
});

I've tried use command mocha --reporter html-cov > test/coverage.html but the coverage is 0% and 0 SLOC.

Aucun commentaire:

Enregistrer un commentaire