Domanda

I just setup my project with mocha, coffeescript and blanket. Mocha and blanket seems to play well with the compiled Javascript, but not the original coffeescript.

This is my code to be tested:

class App
    @add: (a, b) ->
        a + b

    @pow: (exp, base) ->
        if exp == 0
            return 1
        product = 1
        for i in [1..exp]
            product *= base
        product

module.exports = App

Here's my test code:

App = require '../src/app'
assert = require 'assert'

describe 'App', () ->
    describe 'add', () ->
        it 'should return sum of two numbers', () ->
            assert.equal( App.add( 2, 3 ), 5 )

    describe 'pow', () ->
        it 'should return the correct result', () ->
            assert.equal( App.pow( 2, 3 ), 9 )

For CoffeeScript

I ran mocha as the following:

mocha --compilers coffee:coffee-script --require blanket --reporter html-cov > coverage.html

The result shows 0% coverage 0 LOC and nothing else.

For Javascript

However, if I compile those two coffeescript file into javascript, and run the following:

mocha --require blanket --reporter html-cov > coverage.html

The report displays nicely.

So, am I doing something wrong? Because I read the Blanket features and found that Blanket should play well with CoffeeScript. How to make that happen?

È stato utile?

Soluzione

From this post you need this in your package.json:

"blanket": {
    "loader": "./node-loaders/coffee-script"
}
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top