O'Reilly logo

PhantomJS Cookbook by Rob Friesel

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Running QUnit tests with PhantomJS

In this recipe, we will illustrate how to run QUnit-based unit tests through PhantomJS as an alternative to Jasmine.

Getting ready

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required