Using TerminalReporter for unit testing in PhantomJS
This recipe introduces the jasmine-reporters
library, and it explains how to use TerminalReporter
for clear and concise output on the command line when using PhantomJS.
Getting ready
To run this recipe, we will need the following items:
JavaScript code to test, and the tests for that code
The Jasmine testing framework
The
jasmine-reporters
library
Note
The jasmine-reporters
library is a collection of advanced reporters for the Jasmine test framework. It is an open source (MIT licensed) project and is available at https://github.com/larrymyers/jasmine-reporters.
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 tests are available as string-utils-spec.js
under lib
. The test runner is also available in the repository as recipe02-runner.html
under chapter04
. If we run the provided example, we must change to the root directory for the book's sample code.
Lastly...