blittle / jstesting

JS Testing with Jasmine, jsTestDriver, and PhantomJS
57 stars 3 forks source link

jstesting

Browser-based development can sometimes be a challenge when trying utilize code sharing (http://jamisondance.com/2012/6/21/browser-code-sharing-is-terribad/).
Add in module loading, unit testing, and automation...and things get hairy. Until the community comes to a solution, this repo provides a boilerplate for getting up and running with AMD and unit test automation.

Most of what is listed here is learned through painful experience at my day job. If you know of better ways to solve these problems, please let me know!

Javascript unit testing with:

Requirements

The shell scripts assume that the following are installed with binarys available at the local path

Executing the test

This example only has one test spec/fooSpec.js which tests the module src/foo.js

The tests can be started multiple ways:

Viewing Code Coverage

Of the three ways for running the tests above, the latter 2 will provide test output results in testOutputDir. The output is in standard junit xml. The code coverage is located in testOutputDir/jsTestDriver.conf-coverage.dat and is in gcc's lcov format. Use genhtml or something similar to generate html output (or parse the results yourself).