使用jenkins和qunit配置grunt进行自动化JS测试,我实际上已经阻止了这个问题。
当我跑咕噜声时: 跑步" 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找到模块和任务但似乎没有加载它。
答案 0 :(得分:2)
Just at a glance - you are creating your config, but not doing anything with it.
Change this line
grunt.initConfig({
sync: {
target: {}
}
});
to this:
grunt.initConfig(gruntConfig);
You might also want to move that down below all the other stuff you add to gruntConfig.