Book Image

Node.js By Example

Book Image

Node.js By Example

Overview of this book

Table of Contents (18 chapters)
Node.js By Example
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Running our test with PhantomJS


The result of the preceding sections is an automated test that runs in the browser. However, this is very often not enough. We may need to integrate the testing in our deployment processes, and using the browser is not always an option. Thankfully, there is a type of browser called a headless browser. It is a functional browser without a user interface. We still can visit a page, click links, or fill forms, but all of these actions are controlled by code. This is perfect for us and for automated testing.

There are a couple of popular headless browsers. Selenium (https://github.com/seleniumhq/selenium) is one of them. It is well documented and has a big community. Another one is PhantomJS. It plays well with Node.js. So we are going to use it.

We already have several components added to the test environment. To use PhantomJS directly, some supplementary configuration is needed. In order to avoid additional complexity, we will install the mocha-phantomjs module...