Skip to content

Commit

Permalink
Adds optional/examples that a user can add to get Nightwatch/Phpunit …
Browse files Browse the repository at this point in the history
…testing drud#195
  • Loading branch information
mradcliffe committed Mar 26, 2021
1 parent 8dcd10a commit 5ca5e9c
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 0 deletions.
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,3 +85,15 @@ Linux | Docker CE, docker-compose | Your preferred terminal applicat

This may take a few minutes and will provide you with a set of URLs and further instructions for using your contribution environment.

#### Optional configuration

To add Nightwatch to your local environment,

1. Open the `examples/commands/web/` directory.
2. Copy the `nightwatch` and `phpunit` files into the .ddev/commands/web directory of your local instance.
3. Copy the `docker-compose.testing.yaml` file into the .ddev/ directory of your local instance.
4. Open a terminal in the drupal directory of your local instance.
5. Run `ddev restart` if your local instance is running or `ddev start` to start your local instance.
6. Run `ddev exec yarn install` or change directory into drupal/core and run `yarn install`
7. Run `ddev exec nightwatch --tags=core` to run all core Nightwatch tests!

7 changes: 7 additions & 0 deletions examples/commands/web/nightwatch
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash

## Description: Run Nightwatch
## Usage: nightwatch [flags] [args]
## Example: "ddev nightwatch" or "ddev nightwatch --tag core"

yarn --cwd /var/www/html/core test:nightwatch $@
7 changes: 7 additions & 0 deletions examples/commands/web/phpunit
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash

## Description: Run PHPUnit
## Usage: phpunit [flags] [args]
## Example: "ddev phpunit --group big_pipe" or "ddev phpunit core/modules/action"

php ./vendor/bin/phpunit -c core/phpunit.xml.dist $@
32 changes: 32 additions & 0 deletions examples/docker-compose.testing.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
---
# Adds Chromedriver and Drupal PHPUnit test environment variables for running tests.
version: '3.6'
services:
chromedriver:
image: drupalci/chromedriver:production
container_name: ddev-${DDEV_SITENAME}-chromedriver
labels:
com.ddev.site-name: ${DDEV_SITENAME}
com.ddev.approot: $DDEV_APPROOT

web:
links:
- chromedriver:$DDEV_HOSTNAME
environment:
# PHPUnit
SYMFONY_DEPRECATIONS_HELPER: weak
SIMPLETEST_DB: mysql://db:db@db:3306/db
SIMPLETEST_BASE_URL: http://web
BROWSERTEST_OUTPUT_DIRECTORY: /var/www/html/private/browsertest_output
BROWSERTEST_OUTPUT_BASE_URL: $DDEV_PRIMARY_URL
MINK_DRIVER_ARGS_WEBDRIVER: '["chrome", {"browserName":"chrome","chromeOptions":{"args":["--disable-gpu","--headless", "--no-sandbox"]}}, "http://chromedriver:9515"]'

# Nightwatch
DRUPAL_TEST_BASE_URL: http://web
DRUPAL_TEST_DB_URL: mysql://db:db@db:3306/db
DRUPAL_TEST_WEBDRIVER_HOSTNAME: chromedriver
DRUPAL_TEST_WEBDRIVER_PORT: 9515
DRUPAL_TEST_CHROMEDRIVER_AUTOSTART: 'false'
DRUPAL_TEST_WEBDRIVER_CHROME_ARGS: "--disable-gpu --headless --no-sandbox"
DRUPAL_NIGHTWATCH_OUTPUT: reports/nightwatch
DRUPAL_NIGHTWATCH_IGNORE_DIRECTORIES: node_modules,vendor,.*,sites/*/files,sites/*/private,sites/simpletest
3 changes: 3 additions & 0 deletions package_drupal_script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,9 @@ popd >/dev/null
cp -r ${REPO_DIR}/licenses ${REPO_DIR}/COPYING "$STAGING_DIR/"
cp ${REPO_DIR}/.quicksprint_release.txt $REPO_DIR/.ddev_version.txt "$STAGING_DIR/sprint"

# Copy ddev optional commands and configuration.
cp -r ${REPO_DIR}/examples "${STAGING_DIR}/"

cd ${STAGING_DIR}

echo "Creating sprint.tar.xz..."
Expand Down

0 comments on commit 5ca5e9c

Please sign in to comment.