How to test nodejs test code with qunit and grunt. In Gruntfile.js, how to specify only js files. So, in the qunit repo, the Gruntfile.js sample talks about creating html files, and there speI you can see an example of html files that can be tested with grunt, but if I want to check only nodejs backend java script files, then how can I use this? Can someone point to some sample Gruntfile file for this?
My Gruntfile.js is as follows:
module.exports = function( grunt ) {
grunt.loadNpmTasks( "grunt-git-authors" );
grunt.loadNpmTasks( "grunt-contrib-concat" );
grunt.loadNpmTasks( "grunt-contrib-jshint" );
grunt.loadNpmTasks( "grunt-contrib-qunit" );
grunt.loadNpmTasks( "grunt-contrib-watch" );
grunt.initConfig({
pkg: grunt.file.readJSON( "package.json" ),
qunit: {
qunit: [
"src/test.js"
]
},
watch: {
files: [ "*", ".jshintrc", "{src,test}/**/{*,.*}" ],
tasks: "default"
}
});
grunt.registerTask( "build", [ "qunit" ] );
};
And my test.js file looks like this:
test("testing", function(assert) {
var val1 = 10;
equal(10, val1, "We expect to be 10");
});
But when running "grunt qunit" it gives an error below:
Testing src/test.js
>> PhantomJS timed out, possibly due to a missing QUnit start() call.
Warning: 1/1 assertions failed (0ms) Use --force to continue.
Aborted due to warnings.
Please let me know the correct way to mention the Grunt file.
As for -M -