Skip to content

Instantly share code, notes, and snippets.

@jcandan
Created September 28, 2022 11:45
Show Gist options
  • Save jcandan/d15c45fb4d97a0a3712a24e021dac46b to your computer and use it in GitHub Desktop.
Save jcandan/d15c45fb4d97a0a3712a24e021dac46b to your computer and use it in GitHub Desktop.
Behat for Drupal via Lando
name: myproject
recipe: drupal9
config:
webroot: web
services:
appserver:
environment:
MINK_DRIVER_ARGS_WEBDRIVER: '["chrome", null, "http://chromedriver:4444/wd/hub"]'
MINK_DRIVER_ARGS: '["chrome", null, "http://chromedriver:4444/wd/hub"]'
MINK_DRIVER_CLASS: 'Drupal\FunctionalJavascriptTests\DrupalSelenium2Driver'
chromedriver:
type: compose
services:
image: robcherry/docker-chromedriver:latest
expose:
- "4444"
environment:
CHROMEDRIVER_WHITELISTED_IPS: ""
CHROMEDRIVER_URL_BASE: "/wd/hub"
security_opt:
- seccomp:unconfined
command: ["/usr/local/bin/supervisord", "-c", "/etc/supervisord.conf"]
tooling:
behat:
service: appserver
description: Run behat tests locally.
cmd:
- /app/vendor/bin/behat --config=/app/tests/behat/behat.yml

Behat for Drupal via Lando

This assumes an existing Drupal 9+ instance with Lando.

lando composer require behat/behat drupal/drupal-extension drush-ops/behat-drush-endpoint

Don't forget to add appserver to your $settings['trusted_host_patterns'] in settings.php.

Run lando behat --init to initiate the features directory.

Refer to Behat and Drupal Extension documentation for additional help.

# tests/behat/behat.yml
default:
suites:
default:
contexts:
- FeatureContext
- Drupal\DrupalExtension\Context\DrupalContext
- Drupal\DrupalExtension\Context\MinkContext
- Drupal\DrupalExtension\Context\MessageContext
- Drupal\DrupalExtension\Context\DrushContext
extensions:
Drupal\MinkExtension:
goutte: ~
selenium2:
wd_host: http://chromedriver:4444/wd/hub
# Must comment out for BEHAT_PARAMS to be effective.
base_url: http://appserver
Drupal\DrupalExtension:
blackbox: ~
api_driver: 'drupal'
drush:
alias: '@self'
drupal:
drupal_root: '/app/web'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment