nightwatch configuration for drupal: php, docker, nightwatch, end-to-end testing.
1.8K
$ docker pull superelectron/nightwatch:latest
$ docker build -t superelectron/nightwatch:latest .
/commerce
/.docker
/docker-ci-commerce
ci.settings.php
Dockerfile
nginx.conf
README.md
/nightwatch
/node_modules
/reports
/tests
nightwatch.conf.js
package.json
package-lock.json
README.md
/wwwroot
/some-project-files
docker-compose.yml
gitlab-ci.yml
Makefile
make_env file.make_env can be empty, but it suggested to add in this:VERSION = $$(date +%Y-%m-%d)
COMPANY_REPOSITORY = gitlab-registry-name
builds is used with /path/to/webpath/to/web is wwwroot and the project is stored under builds/commerce in the pipeline.server {
listen 8000 default_server;
listen [::]:8000 default_server;
root /builds/commerce/wwwroot;
index index.php index.html index.htm index.nginx-debian.html;
server_name _;
/.docker/docker-ci-projectName and modify nginx.conf for your project.$ docker images
| REPOSITORY | TAG | IMAGE ID | CREATED | SIZE |
|---|---|---|---|---|
| git.company-name.com:xxxx/commerce/nightwatch | latest | 17ce9d54348b | 33 minutes ago | 1.33GB |
$ docker run -d 17ce9d54348b
$ docker ps
| CONTAINER ID | IMAGE | COMMAND | CREATED | STATUS | PORTS | NAMES |
|---|---|---|---|---|---|---|
| 204367467e05 | 17ce9d54348b | "/start.sh" | 3 seconds ago | Up 3 seconds | 80/tcp | vigilant_leavitt |
$ docker exec -it 204367467e05 /bin/bash
root@204367467e05:/# google-chrome --version
Google Chrome 78.0.3904.108
project-name/nightwatch/package.json if needed:"devDependencies": {
"chromedriver": "^78.0.1",
"fs": "0.0.1-security",
"env2": "^2.2.2",
"geckodriver": "^1.19.1",
"glob": "^7.1.6",
"nightwatch": "^1.3.1",
"path": "^0.12.7",
"selenium-server": "^3.141.59",
"request": "^2.88.0"
}
PROJECT_INSTALL_PATH may need a customized variable name besides COMMERCE_INSTALL_PATH$settings['trusted_host_patterns'] can use your customized URLdefine('COMMERCE_INSTALL_PATH', '/app');
define('SERVICES_WORKER_PATH', '/app/scripts/worker.php');
$settings['trusted_host_patterns'] = [
'^127\.0\.0\.1$',
'^nginx$',
'^localhost$'
];
$databases['default']['default'] = array (
'database' => 'drupal',
'username' => 'root',
'password' => 'mysql_strong_password',
'prefix' => '',
'host' => 'mysql',
'port' => '3306',
'namespace' => 'Drupal\\Core\\Database\\Driver\\mysql',
'driver' => 'mysql',
);
$config['system.logging']['error_level'] = 'verbose';
Example:
$ docker build -t git.company-name.com:xxxx/commerce/nightwatch .
$ docker push git.company-name.com:xxxx/commerce/nightwatch
Noteworthy Points
tail -f /dev/null is used to for debugging in the pipeline. TAKE THIS OUT OR IT WON'T PASS THIS POINT!nightwatch-test:
image: git.company-name.com:xxxx/commerce/docker-ci
cache: {}
tags:
- runner3
stage: test
services:
- mysql:5.7
allow_failure: true
artifacts:
when: on_failure
paths:
- e2e/reports
only:
- /^MPF*$/
- /^nightwatch-ci$/
variables:
DRUPAL_BASE_URL: http://localhost
NIGHTWATCH_ADMIN_USER: "admin"
NIGHTWATCH_ADMIN_PASS: "password"
DB_HOST: 'mysql'
DB_NAME: 'drupal'
DB_USER: 'root'
DB_PASSWORD: 'mysql_strong_password'
WEB_ROOT: path/to/web-root
DOWNLOAD_DB_SCRIPT: path/to/script.sh
before_script:
- service nginx start
- service php7.3-fpm start
- ls -al
- cp .docker/docker-ci-commerce/ci.settings.php $WEB_ROOT/sites/default/settings.php
- cd $WEB_ROOT
- drush cc all
- ./$DOWNLOAD_DB_SCRIPT # setup database for website
- tail -f /dev/null
- cd e2e && npm install
script:
- npm run all
keep tail -f /dev/null and when it hits that click debug
check to see if nightwatch is setup: this will not pass if it isn't setup OR you may have a runner which cannot reach the external world!
if this fails, change your gitlab-ci setup to have something either than tags: runner3.
You can test the runner by trying curl www.google.ca after you open the debug terminal.
$ ./node_modules/.bin/nightwatch node_modules/nightwatch/examples/tests/ecosia.js
Content type
Image
Digest
Size
499.1 MB
Last updated
almost 7 years ago
docker pull superelectron/nightwatch