Gruntjs 如何在一个Gruntfile中使用多个mochacov记者并获取报道

Gruntjs 如何在一个Gruntfile中使用多个mochacov记者并获取报道,gruntjs,Gruntjs,目前,我正在Grunfile中切换html cov和json cov并运行命令 grunt mochacov:all > coverage.html 或 以下是my Grunfile.js中配置的json部分: mochacov : { options : { reporter : 'json-cov', //reporter : 'travis-cov', require : ['should'], timeout: 250000, //qu

目前,我正在Grunfile中切换html cov和json cov并运行命令

grunt mochacov:all > coverage.html

以下是my Grunfile.js中配置的json部分:

mochacov : {
  options : {
    reporter : 'json-cov',
    //reporter : 'travis-cov',
    require : ['should'],
    timeout: 250000,
    //quiet : true,
    output : 'coverage.json',
  },
  all: ['test/test-*.js']
},

在默认情况下,通过指定html cov和json cov,我是否可以使用它在输出中同时获得coverage.html和coverage.json?

遗憾的是,默认情况下grunt mocha cov似乎不支持这一点,因为报告者只接受“字符串”


从理论上讲,这在一个咕噜咕噜的多任务中是可能的。

我已经找到了同样的答案:-

这就是我们需要在Gruntfile.js中包含的内容

mochacov: {           
      jsoncoverage: {
        options: {
          reporter: 'json-cov',
          //reporter : 'travis-cov',
          require: ['should'],
          timeout: 250000,
          //quiet : true,
          output: 'reports/coverage.json'
        },
        all: ['test/test-*.js']
      },
      htmlcoverage: {
        options: {
          reporter: 'html-cov',
          //reporter : 'travis-cov',
          require: ['should'],
          timeout: 250000,
          //quiet : true,
          output: 'reports/coverage.html'
        },
        all: ['test/test-*.js']
      }
    }

//and then the following line needs to be there :

grunt.registerTask('mochacoverage', ['mochacov:jsoncoverage', 'mochacov:htmlcoverage']);
然后我们可以使用grunt mochacoverage运行它,它将同时执行html和json

mochacov: {           
      jsoncoverage: {
        options: {
          reporter: 'json-cov',
          //reporter : 'travis-cov',
          require: ['should'],
          timeout: 250000,
          //quiet : true,
          output: 'reports/coverage.json'
        },
        all: ['test/test-*.js']
      },
      htmlcoverage: {
        options: {
          reporter: 'html-cov',
          //reporter : 'travis-cov',
          require: ['should'],
          timeout: 250000,
          //quiet : true,
          output: 'reports/coverage.html'
        },
        all: ['test/test-*.js']
      }
    }

//and then the following line needs to be there :

grunt.registerTask('mochacoverage', ['mochacov:jsoncoverage', 'mochacov:htmlcoverage']);