如何设置 grunt-contrib-nodeunit 来输出 JUnit xml

How to setup grunt-contrib-nodeunit to output JUnit xml?

本文关键字:输出 JUnit xml grunt-contrib-nodeunit 何设置 设置      更新时间:2023-09-26

我找不到任何如何在grunt-contrib-nodeunit模块中设置报告器的信息,现在我的Gruntfile.js中有这个任务。

nodeunit: {
   all: ['nodeunit/**/*.test.js'],
}

如何告诉咕噜咕噜使用带有自定义输出路径的内置 JUnit 报告?

查看代码,您根本无法做到。但是,您可以使用grunt-shell执行此操作:

module.exports = function(grunt) {
  grunt.loadNpmTasks('grunt-shell');
  grunt.initConfig({
    shell:{
      nodeunit_with_junit:{
        command: './node_modules/nodeunit/bin/nodeunit --reporter junit --output ./junit_ouput tests/*.test.js',
        options:{
          stdout: true,
          stderr: true,
          failOnError:false,
          warnOnError: true
        }
      }
    }
  });
};

并用grunt shell:nodeunit_with_junit运行它.

您可以在选项中设置报告器,如下所示:

    nodeunit: {
        client: ['test/unit/client/test*.js'],
        server: ['test/unit/server/test*.js'],
        options: {
            reporter: 'junit',
            reporterOptions: {
                output: '_build'
            }
        }
    },