【问题标题】:istanbul code coverage with mocha tests with coffeescript伊斯坦布尔代码覆盖率与 mocha 测试与咖啡脚本
【发布时间】:2015-02-18 13:36:04
【问题描述】:

我正在使用 mocha 来运行纯咖啡脚本中的测试。我还希望能够使用 istanbul 生成代码覆盖率报告。

注意,我在 mocha.opts 文件中使用带有选项 --compilers coffee:coffee-script/register 的 mocha。

我遇到的问题是没有涵盖需要其他咖啡脚本源文件的测试。如果相反,我需要 js 文件,则可以很好地覆盖。

我错过了什么吗?


我的npm test 命令是:istanbul test --report html -x 'vendor/**' _mocha。我使用npm test --coverage 来强制执行伊斯坦布尔的覆盖实用程序。

这里是一个 mocha 测试示例 (./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()

【问题讨论】:

    标签: node.js coffeescript code-coverage mocha.js istanbul


    【解决方案1】:

    【讨论】:

      【解决方案2】:

      我也一直在寻找这个。看起来 istanbul 不能覆盖 CoffeeScript 文件(尽管有 a pull request open,所以希望我们很快就会看到它)。有一个名为 ibrik 的项目,它使用 istanbul 和 CoffeeScript 解析器来覆盖您的代码。但是,我似乎还没有找到如何将它与 Mocha 集成。 A problem which a lot of people seem to have.

      【讨论】:

      猜你喜欢
      • 2015-08-26
      • 1970-01-01
      • 2015-07-29
      • 2019-04-28
      • 1970-01-01
      • 2015-07-02
      • 1970-01-01
      • 2016-03-04
      • 2015-09-10
      相关资源
      最近更新 更多