Functional JavaScript tests

The last type of tests we can write in Drupal 8 is the JavaScript-powered Functional tests. FunctionalJavascript tests are useful when we want to test more dynamic client-side functionality such as JavaScript behaviors or Ajax interactions.

They are an extension of the regular Functional tests but which use the Phantom.js driver instead of Goutte for Mink in emulating the browser. This also means that in order to run these tests we need to install Phantom.js.

Installing Phantom.js is very simple. We have to go to the website (http://phantomjs.org/download.html) and download the package somewhere onto our system. Since we are using a Linux system so we can pull the archive into our home folder (the following link ...

Get Drupal 8 Module Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.