Chutzpah – A JavaScript Test Runner Released

I just released to CodePlex and the Visual Studio Gallery a new project called Chutzpah (hutz·pah). Chutzpah is an open source JavaScript unit test runner which helps you integrate JavaScript unit testing into your website. It enables you to run JavaScript unit tests from the command line and from inside of Visual Studio. It also supports running in the TeamCity continuous integration server.

Backstory

About nine months ago I asked a question on StackOverflow about whether there were any tools/extensions which integrated into Visual Studio to run JavaScript unit tests. At that time there were no good solutions provided which led me to investigate creating my own tool. I explored many options but eventually I found the PhantomJS headless browser to help drive the tests.  After a couple weeks of development Chutzpah was born.

What does Chutzpah do?

Chutzpah is both a Visual Studio extension and a command line utility.

As a Visual Studio extension:

It allows you to run your JavaScript tests without leaving the IDE. It adds a context menu option to run tests directly from a source file.

RightMenu

It logs test results to both the Error list and the Output window.

errorWindow

outputWindow

As a command line utility:

It allows you to easily integrate test results into your build

commandLine

It also has support for the TeamCity continuous integration server so that you get detailed test output on every build.

How to use it?

Chutzpah is really easy to use, given QUnit tests (it only supports QUnit for now) you can run Chutzpah on the test harness HTML file and it will output the results. Chutzpah also supports running the tests directly from the JavaScript file as long as you add reference comments to the top of your test file.

For example given two files test.js (QUnit tests file) and code.js (implementation file).

code.js

var mathLib = {
    add5: function (a) {
        return a + 5;
    }
}

test.js

/// <reference path="code.js" />

test("will add 5 to number", function () {
    var res = mathLib.add5(10)

    equals(res, 15, "should add 5");
});

You can run the tests by right clicking and choosing “Run JS Test” if you are using the Visual Studio plugin, otherwise you can execute Chutzpah from the command line:

.\chutzpah.console.exe test.js

Community Support

I am really excited about releasing Chutzpah as an open source project with the hope of garnering support from the community. I would love to get feedback, bug reports, feature requests and code contributions. If you are interested in working on Chutzpah fork the code and get hacking.

Future Plans Ideas

At this stage I have many ideas of what features should come next for Chutzpah but outside of bug fixes I have no solid plans yet. Here are several ideas floating around in my head…

  1. Support other JavaScript unit test frameworks besides QUnit
  2. Expand past only using PhantomJS as the headless browser, possibly working with things like JsTestDriver or EnvJS.
  3. Be able to run individual tests instead of just a whole file.
  4. Add better IDE support like the Resharper 6 QUnit functionality.
  5. Add scanning for test files within a whole project hierarchy
  6. Support proxy servers
  7. Capture more detailed information from each test
  8. Integrate with existing test runners like MSTest or TestDriven.NET
  9. Add NuGet support