Last updated April 1, 2021

In order to execute functional tests that require JavaScript be executed for the feature to work the tests need to be run in a browser that supports JavaScript. This is accomplished by using the WebDriver API in combination with an application like ChromeDriver or Selenium which can remotely control a browser.

The exact setup for running functional tests is dependent on your development environment. We'll walk through a couple of common examples including using Docker (via DDEV-Local) and stand-alone applications.

In this tutorial we'll:

  • Learn how to install and run ChromeDriver and other necessary tools either in a Docker environment, or locally.
  • Configure the relevant PHPUnit environment variables so they contain values appropriate for our specific environment.
  • Execute Drupal's functional JavaScript tests via the phpunit command.

By the end of this tutorial you should be able to install the applications required to run functional JavaScript tests in a browser, and know how to configure PHPUnit to make use of them.