Jasmine documentation covers how to get started and run our Specs in the browser, however it’s not enough to run Jasmine Spec with Spec runner html as we have to have special setup on CI.
In this post, we will cover how to setup Jasmine Specs with Grunt to run on CI.
In order to setup Jasmine BDD Specs with grunt, we need a ‘package.json’ file with following dependencies. Assuming we have Node and npm setup.
"description": "Jasmine Demo",
"engine": "node 1.1.x",
Now we can install all these dependencies with ‘npm install’ command. Once installed, we should have ‘node_modules’ directory with all the packages and binaries installed.
Now we have to create a Gruntfile and configure Jasmine Specs using ‘grunt-contrib-jasmine‘ package. Our Example Gruntfile will look like this:
In the Gruntfile.js we have loaded ‘grunt-contrib-jasmine’ package and specified location of our ‘scr’ JS files and ‘Specs’ files.
Now we should be able to execute Grunt ‘jasmine’ task like this
You can see our Specs executed like this :
This can be used to our Jasmine Specs on any Continuous Integration server easily.
Source Code for this demo is available on GitHub : Jasmine-Grunt-Setup