Sample config file when using selenium standalone during test.

docker-compose YAML

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
version: '3'
services:
  test:
    depends_on:
      - selenium
    environment:
      - E2ETEST_HOST=test
      - SELENIUM_PORT=4444
      - SELENIUM_HOST=selenium
    build:
      context: .
      dockerfile: Dockerfile
    ports:
      - "80:80"
      - "443:443"
    command: run_test.sh
  selenium:
    image: selenium/standalone-chrome
    ports:
      - "4444:4444"

nightwatch config sample

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
"test_settings": {
    "default": {
        "selenium_port"  : parseInt(process.env.SELENIUM_PORT) || 4444,
        "selenium_host"  : process.env.SELENIUM_HOST,
        "silent": true,
        "desiredCapabilities": {
            "browserName": "chrome",
            "javascriptEnabled": true,
            "acceptSslCerts": true,
            "chromeOptions" : {
                "args" : ["--no-sandbox"]
            }
        }
    }

run_test.sh

1
2
docker-compose down
docker-compose up --force-recreate --build --abort-on-container-exit --exit-code-from test test