Question

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()
Was it helpful?

Solution

I use coffee-coverage instead with these instructions.

OTHER TIPS

I've been searching around for this as well. It doesn't look like istanbul can cover CoffeeScript files (although there is a pull request open, so hopefully we'll see it soon). There's a project called ibrik which uses istanbul and a CoffeeScript parser to cover your code. However, I can't seem to find how to integrate it with Mocha yet. A problem which a lot of people seem to have.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top