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...