Setup Chutzpah to Run Javascript Tests in VisualStudio

First thing first, install Chutzpah Test Runner and Test Adaptor for the Test Explorer.

Next, setup your projects in Visual Studio. I personally like to keep my test code in a separate project for JavaScript as well so my project and folder structure looks like this:

This allows you to restrict testing frameworks and libraries like Jasmine only to the test project. I use JavaScript libraries directly from the main project when it is needed in test projects as well rather then adding them again in the test project (some people have different view on this but it works for me).

Now, add all the JavaScript files required for your test. This includes
1. testing library/framework files
2. code under test file(s)
3. any additional files required to run code under test

When you are done, your homeSpec.js might look like this

/// <reference path="../../../myapplication.web/scripts/jquery-1.10.2.min.js" />

/// <reference path="../../../myapplication.web/app/app.js" />
/// <reference path="../../../myapplication.web/app/home/homecontroller.js" />

describe('home page', function() {

    it('should return tile as Home', function() {



You can use right click on a test in the code window to run tests in the context or you can right click on a file, folder or project in the solution explorer to run all the tests available in the selected file, folder or project using Chutzpah.

We have not applied any custom configurations for this example because it works out of the box but you can configure Chutzpah by creating chutzpah.json file. The tests can be run using command line as well.

You can find everything you can do with Chutzpah here.

comments powered by Disqus