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 the Karma test runner


This recipe introduces the Karma test runner and describes how to configure it to execute Jasmine tests in PhantomJS. Karma is a test runner that helps make test automation easier by managing the test environments and target browsers, and test reporting for us through simple configuration files.

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 Karma test runner installed

    Note

    Karma is a test runner that is agnostic to any underlying test framework or target browser. We can find out more about it at http://karma-runner.github.io/; we can install it on the command line using npm, as shown:

    npm install karma-cli --global
    npm install karma --save-dev
    
  • And the following plugins (npm modules) for Karma:

    • karma-jasmine

    • karma-phantomjs-launcher

    Note

    Both of these Karma plugins can be installed as regular npm modules on the command line...