Created
June 24, 2014 11:41
-
-
Save mariofink/9b444ecc9f88ab13c589 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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