【发布时间】:2012-03-30 08:55:24
【问题描述】:
我想使用 mocha(node.js 测试框架,而不是 ruby 模拟库)作为库,而不是使用 mocha 可执行文件来运行我的测试。
是否可以通过这种方式运行 mocha 测试?这些示例都只是调用 mocha 库,假设它们已经“需要”,并且 mocha 可执行文件会提前完成所有“需要”,但我真的更喜欢在我的脚本中明确地执行它们,这样我就可以简单地在我的脚本上设置 +x 并直接调用它。
我可以这样做吗?
#!/usr/bin/env coffee
mocha = require 'mocha'
test = mocha.Test
suite = mocha.Suite
assert = require("chai").assert
thing = null
suite "Logging", () ->
setup (done) ->
thing = new Thing()
done()
test "the thing does a thing.", (done) ->
thing.doThing () ->
assert.equal thing.numThingsDone, 1
done()
teardown (done) ->
thing = null
done()
【问题讨论】:
标签: javascript node.js coffeescript mocha.js