我正在使用Coffeescript和node.js编写越来越多的单元测试。我使用coffee的“watch”选项(-w)构建文件。
coffee -w -b -c -o web/ src/
我的问题是运行单元测试需要20秒钟(我假设是编译成.js文件的时间)。
如果可能,我希望在(编译为.js文件后)自动运行单元测试,这将消除等待结果的漫长时间。
我目前的Cakefile:
fs = require 'fs'
{print} = require 'sys'
{spawn, exec} = require 'child_process'
build = (watch, callback) ->
if typeof watch is 'function'
callback = watch
watch = false
options = ['-c', '-b', '-o', 'web', 'src']
options.unshift '-w' if watch
coffee = spawn 'coffee', options
coffee.stdout.on 'data', (data) -> print data.toString()
coffee.stderr.on 'data', (data) -> print data.toString()
coffee.on 'exit', (status) -> callback?() if status is 0
task 'test', 'Run the test suite', ->
build ->
require.paths.unshift __dirname + "/lib"
{reporters} = require 'nodeunit'
process.chdir __dirname
reporters.default.run ['test']
.coffee
文件并查看哪些(如果有)需要超过1秒才能编译完成。然后将报告发布到问题跟踪器中。 - Trevor Burnham