我已经用摩卡设置了咕噜声。它运行正常,但如果测试不时失败,我想获得更详细的报告。当然,我只想运行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?
答案 0 :(得分:1)
5分钟后,自然而然地得到了它。诀窍是在命令行:
使用grunt watch:coffee
访问grunt测试。.
。但您可以通过grunt.registerTask "spectest", ->
configPos = "mochaTestConfig.options.reporter"
grunt.log.writeln('before modif config: ' + grunt.config configPos) # nyan
grunt.config configPos, "spec"
grunt.log.writeln('after modif with config: ' + grunt.config configPos) # spec
grunt.task.run('mochaTest')
表示法修改该配置:
{{1}}