A simple lib to help you running Javascript unit tests inside a Java application.
-
Build the JAR and install it locally with
mvn install
; -
Include the JAR and the dependencies in your application, preferably using Maven:
br.com.caelum jstestrunner 1.2.0-SNAPSHOT -
In your project, extend the
JavascriptTestSuite
class as desired to fit your application structure and Javascript testing frameworks (see below); -
Run it as a JUnit test case (in your IDE, in the command line or in your continuous integration tool).
Extend the JavascriptTestSuite class, passing the JS test framework adapter to the superclass, and then use your customized class to run the tests.
public class MyJSTests extends JavascriptTestSuite {
public MyJSTests() {
super(new ScrewUnit());
}
}
Don't forget to implement the static suite
method on your class.
More instructions can be found on JavascriptTestSuite javadoc.
Many thanks to Caires Santos (cairesvs) and Lucas Cavalcanti (lucascs) for the help and original code.