JavaScript Unit Testing with Hudson and JasmineBDD


  • JasmineBDD, a JavaScript BDD/ TDD framework
  • The JUnitXmlReporter from Jasmine Reporters
  • Envjs (embedded with the Jasmine Reporters download)
  • Hudson Jenkins (continuous integration server) on a Linux slave


  • let Hudson execute a (Java) shell command
  • let Java run Envjs
  • let Envjs run a simple JavaScript which loads an HTML file (your JasmineBDD test runner)


The Java command:
java -cp lib/envjs/js.jar:lib/envjs/jline.jar -opt -1 -f lib/envjs/envjs.bootstrap.js -f test.js
(The libs and the bootstrap file came with Envjs in the Jasmine Reporters download.)

The test.js content:
window.location = 'SpecRunner.html';
(I.e., opening the JasmineBDD spec runner.)

Simple Unit Testing Only

So far, this only works for simple unit testing for me.  F.ex., it won’t play nice with prototype (which is really integration testing, but still).

It’s probably got something to do with Envjs’ limitations compared to a full web browser.

But hey, headless automatic JavaScript unit testing ain’t bad 🙂

@ingesol got Hudson to run Jasmine using JsTestDriver and Jasmine JsTestDriver Adapter.  (See guide to Hudson and JSTD.)

It’s not headless – requires running JSTD server and browsers, but it will handle prototype et al.

Update 2:

Headless testing as described above is not only for simple unit testing – jQuery works fine, too.  There’s advantages to running a JsTestDriver server, especially catching browser quirks, but for much of the BDD/ TDD effect (testable code, design, executable requirements, etc) you can run headless testing continuously in Hudson without any “external help”…