Example of using Drupal's Nightwatch.js test suite
This repository is based on a Composer build and not meant for core contributions, it is fine for contrib.
To set up your own core contribution environments follow the following:
git clone https://git.drupalcode.org/project/drupal.git
cd drupal
# If lando
wget https://raw.githubusercontent.com/bluehorndigital/drupal-testing-workshop/main/.lando.yml
# if DDEV
ddev config --yes
cd .ddev
wget https://raw.githubusercontent.com/bluehorndigital/drupal-testing-workshop/main/.ddev/docker-compose.testing.yaml
When running headless Chrome via Chromedriver in a container, you must specify
the --no-sandbox
flag. Without this flag, Chrome will not start. This can be
mitigated if the container has an appropriate user configured (the DrupalCI image
used here does not*)
Source: https://developers.google.com/web/updates/2017/04/headless-chrome
* The example provided by Google shows an example from Lighthouse Bot that sets the user to chrome
. The drupalci/chromedriver
performs nearly the same operation but as chromeuser
. I have opened an issue for the DrupalCI image here: https://www.drupal.org/project/drupalci_environments/issues/3205271
Probably memory. Umami demo takes a lot to install.
- Write up how to do this locally
- Lando complains
private/browsertest_output
is not writeable, it should be generated on install but is missing
Getting tests running: Locally
Locally using
https://mglaman.dev/blog/my-phpunit-configuration-my-drupal-projects
There are DDEV commands to run PHPUnit and Nightwatch setup in this project.
ddev phpunit core/modules/action
ddev nightwatch --tag core
Commands documented: https://ddev.readthedocs.io/en/stable/users/extend/custom-commands/#container-commands
Blogs:
- Running Drupal's PHPUnit test suites on DDEV
- Running Drupal's FunctionalJavascript tests on DDEV
- Running Drupal's Nightwatch test suite on DDEV
With tooling definitions preconfigured in this project, we can run the tests
lando phpunit core/modules/action
lando nightwatch --tag core