【发布时间】:2013-05-20 14:18:21
【问题描述】:
我已经用 mocha 设置了 grunt。它运行良好,但如果测试不时失败,我想获得更详细的报告。自然我只想运行grunt detailedTest 而不是每次都修改 grunt 文件。我以为我可以:
- 创建一个名为detailedTest 的新grunt 任务
- 设置该测试以更改摩卡测试仪的配置
- 然后运行测试
看起来像:
grunt.initConfig
watch:
...
mochaTest:
files: [ 'test/calc/*.coffee', 'test/*.coffee']
mochaTestConfig:
options:
reporter: 'nyan'
timeout: 500
grunt.registerTask "spectest", ->
grunt.config "mochaTestConfig:options:reporter", "spec"
grunt.log.writeln('done with config: '
+ grunt.config "mochaTestConfig:options:reporter")
grunt.task.run('mochaTest')
然后输出:
$ grunt spectest
Running "spectest" task
done with config: spec
Running "mochaTest:files" (mochaTest) task
230 _-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_ ...etc
该死的,那不是规格记者。如何在测试前修改配置?或者我应该以某种方式从命令行将值传递给 grunt?
【问题讨论】:
标签: coffeescript mocha.js gruntjs