【问题标题】:Grunt no "qunit" targets found咕噜声没有找到“qunit”目标
【发布时间】:2016-08-31 16:37:44
【问题描述】:

配置 grunt 以使用 jenkins 和 qunit 进行自动化 JS 测试,我实际上是在阻止这个问题。

当我运行 grunt 时: 运行“qunit_junit”任务

XML 报告将被写入 _build/test-reports 未找到“qunit”目标。 警告:任务“qunit”失败。使用 --force 继续。

Aborted due to warnings.

我的 Gruntfile:

'use strict';

module.exports = function(grunt) {

    var gruntConfig = {};

    grunt.initConfig({
    sync: {
        target: {}
    }
    });

    grunt.registerTask('default', ['qunit_junit', 'qunit']);
    grunt.loadNpmTasks('grunt-contrib-qunit');
    grunt.loadNpmTasks('grunt-qunit-istanbul');
    gruntConfig.qunit = {
    src: ['static/test/index.html'],
        options: {
            coverage: {
        src: ['static/js/**/*.js'],
        instrumentedFiles: 'temp/',
        htmlReport: 'report/coverage',
        coberturaReport: 'report/',
                linesThresholdPct: 20
            }
        }
    };
    grunt.loadNpmTasks('grunt-qunit-junit');
    gruntConfig.qunit_junit = {
        options: {
            dest: 'report/'
        }
    };

};

我检查了 node_modules 中的 console.log(),安装了 grunt-contrib-qunit 并且任务在其中,所以 grunt 找到了模块和任务,但似乎没有加载它。

【问题讨论】:

    标签: javascript gruntjs


    【解决方案1】:

    一目了然 - 您正在创建配置,但没有对其进行任何操作。

    改变这一行

    grunt.initConfig({
      sync: {
        target: {}
      }
    });
    

    到这里:

    grunt.initConfig(gruntConfig);
    

    您可能还想将它移到您添加到 gruntConfig 的所有其他内容之下。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-04-18
      • 2015-05-25
      • 1970-01-01
      • 2015-04-13
      • 2013-03-15
      • 2015-08-03
      • 1970-01-01
      相关资源
      最近更新 更多