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

Introduction


One of the most popular uses of PhantomJS among front-end developers is as the primary testing environment for fast unit tests during development. Since PhantomJS is a headless web browser, it can sit invisibly on the command line waiting for tests to be triggered—totally unobtrusive until tests fail and it's time to raise the alarm.

In this chapter, we will learn about using PhantomJS as just such an environment for JavaScript unit tests. The chapter will focus on the Jasmine test framework, but will also introduce two other popular frameworks, QUnit and Mocha. The recipes in this chapter will look at a trivial string utilities library (string-utils.js under lib in the sample repository), and tests for that library will provide the subject matter that underlies each of the testing strategies discussed.