- Envjs - Simulated Browser environment
- PhantomJS - Headless Webkit browser
- QUnit - Unit Testing Framework
- JsTestDriver - Framework for Unit Tests
So what to use now ?
So I started with JSTest Driver since it seems to be the one which has all the features I wanted.
JS Test Driver
After some fiddeling around I got the Maven test to run. The last commit of the maven plugn was around August 2011.
To use the plugin configure it like this (full code in the example code on github).
<plugin> <groupId>com.googlecode.jstd-maven-plugin</groupId> <artifactId>jstd-maven-plugin</artifactId> <version>126.96.36.199</version> <configuration> <port>9876</port> <browser>/Apps/Firefox12.app/Contents/MacOS/firefox-bin</browser> </configuration> <executions> <execution> <id>run-tests</id> <goals> <goal>test</goal> </goals> </execution> </executions> </plugin>
What I do not like at the moment is the specification of the browser path. This might make it hard to run the same configuration on a local machine and in a ci build. Yes, I don’t want to go down the path of maven profiles. Even with that you might have the issue of the port configuration. Two testruns at the same time and both starting the server on the same port calls fro trouble.
mvn test shows me something like:
... [INFO] [INFO] --- jstd-maven-plugin:188.8.131.52:test (run-tests) @ jstestdriver-demo --- ------------------------------------------- J S T E S T D R I V E R ------------------------------------------- .F Total 2 tests (Passed: 1; Fails: 1; Errors: 0) (1.00 ms) Firefox 12.0 Mac OS: Run 2 tests (Passed: 1; Fails: 1; Errors 0) (1.00 ms) Echo Test.testHello2 failed (0.00 ms): AssertError: ...
The full demo code is available on GitHub.
Any thoughts ?