- Jasmine: http://pivotal.github.com/jasmine/
- QUnit: http://docs.jquery.com/QUnit
- Mocha: http://visionmedia.github.io/mocha/
- Chutzpah: https://github.com/mmanela/chutzpah
- PhantomJS: http://www.phantomjs.org/
Visual Studio Setup
To get Chutzpah set up in Visual Studio could not be easier. You simply need to install the Nuget Package from the manager. There are multiple method to do this, but the one I use is this.
- Open Visual Studio (version 2013 is used in the graphics)
- Click on ‘Tools’ from the top menu
- Click on ‘NuGet Package Manager’ then ‘Manage NuGet Packages for Solution…’
- Once the manager window pops up, search for ‘chutzpah’
- Install this NuGet package.
You now have it installed and you should see the unit testing icons next to your tests. For example, I use Qunit and it looks like this.
You will also notice if you are using Qunit that I have the ‘setup’ property in my module. This is because Chutzpah is running Qunit 1.23.1, not the latest 2.x. Therefore I would check what version testing framework you are using and if it is supported. You might want to use a different test runner or downgrade your framework.
Building with Team Foundation Server
Now I’m not going to go through how to use the TFS build definitions as this is a whole huge subject itself. However I would like to show how I got Chutzpah running on build as when researching I found only snippets scattered.
The method to do this is to run it via the command line, so I know most peoples ‘Build process templates’ will be different, but this is mine. In the build process template, I have a ‘Post-test script path’ and the arguments inputs. In these I put the commands.
As you will see I have a destination to the console exe application for Chutzpah. This is downloaded with the NuGet package and so should be in the same location for everyone. For copy and pasting people here is the destination:
As well as other parameters, the exe takes the directory location of where the tests are held. As the build would run from the root of the project, I have done the same. This is why the exe directory starts from packages and the arguments would also start from there. If you have one script you might put the file name at the end as well, but if you want to run all tests in a directory then only go as deep as you need.
You can test the running of this by opening the project directory in command line and running the same command. Quick-tip to get to the directory faster is to open it in File Explorer, then type ‘cmd’ in the address bar and click enter as below:
Once open you can run the command like this:
You should then get the below: