Skip to content

Instantly share code, notes, and snippets.

@mariofink
Created June 24, 2014 11:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mariofink/9b444ecc9f88ab13c589 to your computer and use it in GitHub Desktop.
Save mariofink/9b444ecc9f88ab13c589 to your computer and use it in GitHub Desktop.
module.exports = function (grunt) {
grunt.initConfig({
/**
* Build JS code from AMD modules with Browserify
*/
browserify: {
testspecs: {
src: ["scripts/test/spec/<%= browserifySpecs %>.js"],
dest: 'scripts/test/specs-built.js'
}
},
/**
* Jasmine is used for JavaScript init testing - runs against a spec file that will be pre-built by browserify:test task
*/
jasmine: {
src: "scripts/test/specs-built.js"
}
});
// Load plugins here
grunt.loadNpmTasks('grunt-contrib');
grunt.loadNpmTasks('grunt-browserify');
grunt.loadNpmTasks('grunt-contrib-jasmine');
// JavaScript unit testing with Jasmine
// browserify is used to pre-build the test specs. This is required because browserify doesn't expose modules to the global namespace.
// If you simply run "grunt test" it will run all tests inside the test/spec folder
// If you just want to run a single test spec, you can do this "grunt test:transport" - this will only run the spec transport.js
grunt.registerTask('test', "JavaScript unit testing", function(specToBuild) {
grunt.config.set("browserifySpecs", "**/*");
if (specToBuild) {
grunt.config.set("browserifySpecs", specToBuild);
}
grunt.task.run(['browserify:testspecs', 'jasmine']);
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment