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 Mocha unit tests with PhantomJS


This recipe demonstrates how to run Mocha-based unit tests through PhantomJS as an alternative to Jasmine and QUnit.

Getting ready

To run this recipe, we will need the following items:

  • JavaScript code to test, and the tests for that code

  • Node.js and npm installed and on our PATH

  • The Mocha test framework (included in lib/mocha)

    Note

    Mocha is the "simple, flexible, and fun" JavaScript unit-testing framework that runs in Node.js or in the browser. It is open source (MIT licensed), and we can learn more about it at http://visionmedia.github.io/mocha/; we can install Mocha on the command line using npm, as follows:

    npm install --global mocha
    
  • The Chai assertion library (included in lib/chai)

    Note

    Chai is a platform-agnostic BDD/TDD assertion library featuring several interfaces (for example, should, expect, and assert). It is open source (MIT licensed), and we can learn more about it at http://chaijs.com/; we can install Chai on the command line using npm, as follows...