繁体   English   中英

CoffeeScript +摩卡咖啡+毯子,怎么办?

[英]CoffeeScript + Mocha + Blanket, how to?

我只是用摩卡咖啡,咖啡脚本和毯子来设置我的项目。 摩卡和毯子似乎可以很好地与已编译的Java脚本一起使用,但不能与原始的咖啡脚本一起使用。

这是我要测试的代码:

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

这是我的测试代码:

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 )

对于CoffeeScript

我按照以下方式运行摩卡咖啡:

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

结果显示0% coverage 0 LOC ,仅此而已。

对于Javascript

但是,如果我将这两个coffeescript文件编译为javascript,然后运行以下命令:

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

该报告显示效果很好。

所以,我做错什么了吗? 因为我阅读了Blanket功能,发现Blanket可以与CoffeeScript一起很好地玩。 如何做到这一点?

从这篇文章中,您需要在package.json

"blanket": {
    "loader": "./node-loaders/coffee-script"
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM