我已经用摩卡咕噜咕噜地设置了。它运行良好,但如果测试不时失败,我想获得更详细的报告。自然,我只想运行grunt detailedTest而不是每次都修改 grunt 文件。我以为我能够:
- 新建一个名为 detailTest 的 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?