Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to setup chromedriver to test javascript files #27

Open
smustgrave opened this issue May 28, 2022 · 1 comment
Open

How to setup chromedriver to test javascript files #27

smustgrave opened this issue May 28, 2022 · 1 comment

Comments

@smustgrave
Copy link

Anyone know how to setup a chromedriver to test FunctionalJavascript files ?

@rtfm-47 rtfm-47 transferred this issue from lando/lando May 28, 2022
@almunnings
Copy link
Sponsor

almunnings commented May 29, 2024

Just kinda stumbled on this.

You might have some luck with the below

services:
  chrome:
    type: compose
    app_mount: false
    services:
      image: drupalci/webdriver-chromedriver:production
      security_opt:
        - seccomp:unconfined
      command: chromedriver --verbose --allowed-ips= --allowed-origins=*
      platform: linux/amd64

tooling:
  phpunit:
    env:
      SIMPLETEST_BASE_URL: http:https://appserver
      SIMPLETEST_DB: 'mysql:https://drupal10:drupal10@database/drupal10'
      SYMFONY_DEPRECATIONS_HELPER: 'disabled'
      MINK_DRIVER_ARGS_WEBDRIVER: '["chrome", {"browserName":"chrome","chromeOptions":{"args":["--disable-gpu","--headless","--no-sandbox"]}}, "http:https://chrome:9515"]'
    cmd:
      - appserver: /app/vendor/bin/phpunit -c /app/web/core/ --stop-on-failure /app/web/modules/custom

Or alternatively, using seleniarm/standalone-chromium (like ddev) and configure everything:

services:
  chrome:
    type: compose
    app_mount: false
    expose:
      - "4444"
    services:
      image: seleniarm/standalone-chromium:latest
      security_opt:
        - seccomp:unconfined
      command: /opt/bin/start-selenium-standalone.sh

tooling:
  phpunit:
    env:
      # Drupal tests
      SYMFONY_DEPRECATIONS_HELPER: 'disabled'
      BROWSERTEST_OUTPUT_BASE_URL: 'https://YOURLANDODOMAIN.lndo.site'
      BROWSERTEST_OUTPUT_DIRECTORY: /tmp
      SIMPLETEST_BASE_URL: &SIMPLETEST_BASE_URL http:https://appserver
      SIMPLETEST_DB: &SIMPLETEST_DB 'mysql:https://drupal10:drupal10@database/drupal10'
      MINK_DRIVER_ARGS_WEBDRIVER: &MINK_DRIVER_ARGS_WEBDRIVER '[\"chrome\", {\"browserName\":\"chrome\",\"goog:chromeOptions\":{\"w3c\":false,\"args\":[\"--disable-gpu\",\"--headless\", \"--no-sandbox\", \"--disable-dev-shm-usage\"]}}, \"http:https://chrome:4444/wd/hub\"]'
      # Nightwatch
      DRUPAL_TEST_BASE_URL: *SIMPLETEST_BASE_URL
      DRUPAL_TEST_DB_URL: *SIMPLETEST_DB
      DRUPAL_TEST_WEBDRIVER_HOSTNAME: selenium-chrome
      DRUPAL_TEST_WEBDRIVER_PORT: 4444
      DRUPAL_TEST_WEBDRIVER_PATH_PREFIX: /wd/hub
      DRUPAL_TEST_WEBDRIVER_CHROME_ARGS: --disable-gpu --headless --no-sandbox --disable-dev-shm-usage
      DRUPAL_TEST_CHROMEDRIVER_AUTOSTART: false
      DRUPAL_NIGHTWATCH_SEARCH_DIRECTORY: ../
      DRUPAL_NIGHTWATCH_IGNORE_DIRECTORIES: node_modules,vendor,.*,sites/*/files,sites/*/private,sites/simpletest
      DRUPAL_NIGHTWATCH_OUTPUT: reports/nightwatch
      # DTT
      DTT_BASE_URL: *SIMPLETEST_BASE_URL
      DTT_MINK_DRIVER_ARGS: *MINK_DRIVER_ARGS_WEBDRIVER
    cmd:
      - appserver: /app/vendor/bin/phpunit -c /app/web/core/ --stop-on-failure web/modules/custom

2 years late?! Hopefully it helps someone.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants