I am actually configuring grunt with qunit to run unit tests with jenkins (following this tutorial: http://shashikantjagtap.net/javascript-continuous-integration-jenkins-qunit-grunt/ ) but I am actually blocked by this error:
ReferenceError: gruntConfig is not defined Warning: Task "qunit_junit" not found. Use --force to continue.
Aborted due to warnings.
my devDependencies:
"devDependencies": {
"grunt": "^1.0.0",
"grunt-cli": "0.1.6",
"grunt-contrib-clean": "~0.4.0",
"grunt-contrib-connect": "~0.6.0",
"grunt-contrib-csslint": "*",
"grunt-contrib-jshint": "~0.7.0",
"grunt-contrib-qunit": "~0.3.0",
"grunt-parallel-behat": "*",
"grunt-qunit-cov": "~0.3.2",
"grunt-qunit-istanbul": "*",
"grunt-qunit-junit": "^0.1.1",
"grunt-cli": "0.1.6",
"gulp": "github:gulpjs/gulp#4.0",
"gulp-apidoc": "^0.2.3",
"gulp-documentation": "^2.2.0",
"gulp-eslint": "^2.0.0",
"gulp-istanbul": "^0.10.3",
"gulp-jscs": "^4.0.0",
"gulp-mocha": "^2.2.0",
"gulp-nodemon": "^2.0.6",
"istanbul": "^0.4.4",
"mocha": "^3.0.2",
"require-dir": "^0.3.0",
"should": "^8.3.0",
"supertest": "^1.2.0"
}
and my Gruntfile.js:
module.exports = function (grunt) {
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/'
}
};
}
Anyone encountered this error or have an idea on how to fix it ?
Have a look at the sample Gruntfile:
module.exports = function(grunt) {
grunt.initConfig({
jshint: {
files: ['Gruntfile.js', 'src/**/*.js', 'test/**/*.js'],
options: {
globals: {
jQuery: true
}
}
},
watch: {
files: ['<%= jshint.files %>'],
tasks: ['jshint']
}
});
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.registerTask('default', ['jshint']);
};
As stated in the ReferenceError
: you have not defined the gruntConfig
object. Add var gruntConfig = {};
to define the object.
module.exports = function (grunt) {
grunt.registerTask('default', ['qunit_junit', 'qunit']);
grunt.loadNpmTasks('grunt-contrib-qunit');
grunt.loadNpmTasks('grunt-qunit-istanbul');
//Add the below line to defined the object.
var gruntConfig = {};
gruntConfig.qunit = { ... }
//code ...
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.