Skip to content

How to setup chromedriver to test javascript files #27

Open

Description

@smustgrave

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

Activity

  1. transferred this issue fromlando/landoon May 28, 2022
  2. almunnings commented on May 29, 2024

    @almunnings

    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://appserver
          SIMPLETEST_DB: 'mysql://drupal10:drupal10@database/drupal10'
          SYMFONY_DEPRECATIONS_HELPER: 'disabled'
          MINK_DRIVER_ARGS_WEBDRIVER: '["chrome", {"browserName":"chrome","chromeOptions":{"args":["--disable-gpu","--headless","--no-sandbox"]}}, "http://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://appserver
          SIMPLETEST_DB: &SIMPLETEST_DB 'mysql://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://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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions