Update Nightwatch for Drupal 10

Created on 17 December 2024, 4 months ago

Problem/Motivation

Currently we are pinned to Nightwatch 2.4.2 because upgrading further broke CI, but maybe other infrastructure changes we have made mean we can upgrade now? Let's find out.

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

Introduced terminology

API changes

Data model changes

Release notes snippet

πŸ“Œ Task
Status

Active

Version

10.5 ✨

Component

javascript

Created by

πŸ‡¬πŸ‡§United Kingdom longwave UK

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @longwave
  • Merge request !10594Update Nightwatch to 2.6.25. β†’ (Open) created by longwave
  • πŸ‡³πŸ‡±Netherlands spokje

    I tried this but also got shipwrecked on the Selenium session bit, probably some new config option we have to pass somewhere?

    Oh, and all the resolutions we all love to hate in the package.json are there because of Nightwatch holding at 2.4.2.
    If we get it higher, we can drop all of them AFAICT.

  • πŸ‡³πŸ‡±Netherlands spokje

    And as a side-note: This MR also seems to bump cspell from version "8.16.1" to version "8.17.1".
    Perhaps by deleting the yarn.lock before doing a yarn install?

  • πŸ‡ΊπŸ‡ΈUnited States cpierce42

    I've been experimenting with this in lando (wsl2, drupal 10.4) tying to upgrade nightwatchjs to version 3.11.0.
    This ticket https://www.drupal.org/project/drupal/issues/3371963#comment-15134159 πŸ“Œ Update Nightwatch to 3.x Fixed said it would be ported into D10.3+ but it did not get rolled in.

    I am attempting to re-work the merge reqeust that was submitted and making it work but there is something missing.

    I got it pretty close where it starts a selenium server but hangs:

    Starting Selenium Server [selenium-server-4.20.0.jar] on port 9515...
    

    Nothing else happens and the log file is blank.

    Specifically to get to this point I preformed the following steps:
    write a patch to allow changes from the above mentioned ticket to apply in composer
    Install linux current chromium driver on both wsl and in the lando build_as_root apt install libnss3-dev libgdk-pixbuf2.0-dev libgtk-3-dev libxss-dev

    In my lando file I have a lot of changes:

      appserver:
        webroot: docroot
        xdebug: 'develop,debug'
        ssl: true
        config:
          php: .lando.php.ini
        build_as_root:
          # Nightwatch config
          - curl -sL https://deb.nodesource.com/setup_18.x | bash -
          - apt install libnss3-dev libgdk-pixbuf2.0-dev libgtk-3-dev libxss-dev
          - apt-get install -y nodejs
          - npm install -g yarn
        run:
          - mkdir -p private/browsertest_output
          - yarn add @nightwatch/vrt --cwd /app/docroot/core
          - yarn add @nightwatch/selenium-server --cwd /app/docroot/core
          - yarn install --non-interactive --cwd /app/docroot/core
          # Override nightwatch config to our custom config that includes vrt
          # This will break on upgrade to drupal 11. Nightwatch tests will need to be upgraded to api v3
    # copy my saved .env and config file into the core folder to ease of setup and testing
          - cp /app/Nightwatch/nightwatch.conf.js /app/docroot/core/tests/Drupal/Nightwatch/nightwatch.conf.js
          - cp /app/Nightwatch/.env /app/docroot/core/.env
        overrides:
          environment:
            # Support debugging CLI with Xdebug.
            PHP_IDE_CONFIG: "serverName=appserver"
            # nightwatch config, probably not needed as we have the .env file
            SIMPLETEST_BASE_URL: "https://mytest.lndo.site"
            SIMPLETEST_DB: "mariadb://drupal10:drupal10@database:3306/drupal10"
            BROWSERTEST_OUTPUT_DIRECTORY: '/app/docroot/sites/simpletest/browser_output'
            BROWSERTEST_OUTPUT_BASE_URL: 'https://mytest.lndo.site'
            MINK_DRIVER_ARGS_WEBDRIVER: '["chrome", {"browserName":"chrome","chromeOptions":{"args":["--disable-gpu","--headless","--no-sandbox"]}}, "http://chrome:9515"]'        # Nightwatch
            DRUPAL_TEST_BASE_URL: 'https://mytest.lndo.site'
            DRUPAL_TEST_DOCKER: TRUE
            DRUPAL_TEST_DB_URL: 'mariadb://drupal10:drupal10@database:3306/drupal10'
            DRUPAL_TEST_WEBDRIVER_HOSTNAME: chrome
            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
      chrome:
        type: compose
        scanner: false
        app_mount: false
        services:
          image: drupalci/chromedriver:production
          expose:
            - "9515"
            - "4444"
          volumes:
            - /dev/shm:/dev/shm
          security_opt:
            - seccomp:unconfined
          command: ["chromedriver",  "--log-path=/tmp/chromedriver.log", "--verbose", "--allowed-ips=", "--allowed-origins=*", "--whitelisted-ips="]
          external_links:
          - appserver:mytest.lndo.site
    

    In the nightwatch.config.js file I changed the selenium start_process to true, added plugins:['@nightwatch/vrt']

Production build 0.71.5 2024