In this recipe, we will illustrate how to run QUnit-based unit tests through PhantomJS as an alternative to Jasmine.
To run this recipe, we will need JavaScript code to test, and the tests for that code. To test our code, we will use the QUnit test framework.
Note
QUnit (maintained by the jQuery Foundation) is a JavaScript framework for writing unit tests; its assertion methods conform to the CommonJS unit testing specification (see http://wiki.commonjs.org/wiki/Unit_Testing/1.0). QUnit is open source (MIT licensed) and is available at http://qunitjs.com/.
We will be using QUnit version 1.14.0.
The library code that we will use for our tests is available in the downloadable code repository as string-utils.js
under lib
; the accompanying QUnit tests are available as string-utils-tests.js
under lib
. The test runner is also available in the repository as recipe09-runner.html
under chapter04
. If we run the provided example, we must change to the root...