JS Test Runner

Imagine invoking a suite of JavaScript Unit Tests from within your favourite IDE in the way you are used to for other languages. Here is JS Test Runner executing from within Eclipse; it is invoked via the regular "Run As.../JUnit Test menu":

The goal of the JS Test Runner is to be able to test JavaScript (JS) code using an approach that test driven programmers will feel comfortable with; particularly in the context of Continuous Integration (CI).

JS Test Runner provides a JUnit "test runner" based solution that calls upon a "headless browser" to execute unit tests. At present the runner uses PhantomJS as its headless browser. PhantomJS is WebKit browser with no graphical user interface; it has a command line interface. JS Test Runner is also loosely coupled with JUnit so it should be possible to integrate it with others including TestNG .

Here is a typical usage of JS Test Runner. This sample will pick up all QUnit tests in the target/test-classes folder:

import org.codehaus.jstestrunner.junit.JSTestSuiteRunner;
import org.junit.runner.RunWith;

/**
 * Run all JS tests associated with this project.
 */
@RunWith(JSTestSuiteRunner.class)
public class SuiteUT {
}

Being associated with JUnit means that JS Test Runner can be leveraged by Maven's Surefire plugin and indeed virtually anything else that runs JUnit tests. The combination of JS Test Runner and Surefire makes CI possible using familiar configuration. That said, there is no dependency on Maven by this project so other CI possibilities are available including being driven by ANT, make and so forth. Here is JS Test Runner executing from within Maven:

-------------------------------------------------------
 T E S T S
-------------------------------------------------------
Running SuiteUT
Tests run: 8, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 3.157 sec

Results :

Tests run: 8, Failures: 0, Errors: 0, Skipped: 0
Please note that snapshots of this project are available at the https://nexus.codehaus.org/content/repositories/snapshots repository.