Book Image

PhantomJS Cookbook

By : Rob Friesel
Book Image

PhantomJS Cookbook

By: Rob Friesel

Overview of this book

Table of Contents (15 chapters)
PhantomJS Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Running Jasmine unit tests with PhantomJS


This recipe will illustrate a basic Jasmine-based test suite and how to execute its test runner under PhantomJS while extracting useful test feedback.

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 Jasmine test framework.

Note

Jasmine is a JavaScript framework used for writing tests in a behavior-driven development (BDD) style. We will use it here because it is widely used, and the tests are generally easy to read. Jasmine is open source (MIT licensed) and we can find its documentation at http://jasmine.github.io/.

We will be using Jasmine version 1.3.1; we can download this version at https://github.com/pivotal/jasmine/tree/v1.3.1.

The library code that we will test 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...