Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

istanbul code coverage with mocha tests with coffeescript

I'm using mocha to run tests that are purely in coffeescript. I also want to be able to use istanbul to generate code coverage reports.

Note, I'm using mocha with option --compilers coffee:coffee-script/register within the mocha.opts file.

The issue I'm running into is that tests that require other coffeescript source files aren't covered. If instead, I require js files, it's covered fine.

Am I missing something?


My npm test command is: istanbul test --report html -x 'vendor/**' _mocha. I use npm test --coverage to enforce istanbul's coverage utility.

Here is a sample of a mocha test (./test/test.coffee):

# Project
# require ../src/main.coffee
main = require('../src/main')

# Chai
chai = require('chai')

assert = chai.assert
should = chai.should()
expect = chai.expect


describe 'something', (done) ->

  describe "when given something", ->

    it "should do this", ->
        # tests using chai API here
        something = new main()
like image 421
Alberto Leal Avatar asked Nov 10 '22 10:11

Alberto Leal


1 Answers

I use coffee-coverage instead with these instructions.

like image 188
Greg Slepak Avatar answered Dec 01 '22 21:12

Greg Slepak