Score:0

Why are Nightwatch tests failing in this Lando environment?

jm flag

I'm setting up Nightwatch for drupal 9 in Lando based project. When executing the lando nightwatch --tags core. All the test cases are failing (even the core). Below is the lando.yml file.

name: night-watch-test
recipe: drupal9
config:
 webroot: docroot
 xdebug: false
 php: '8.0'
 composer_version: '2'
 config:
   php: .lando/php.ini
   mysql: .lando/mysql.cnf
proxy:
 appserver:
   - site1.lndo.site
   - site2.lndo.site
 search:
   - search.site1.lndo.site:8983
services:
 drupal:
   type: mysql
   portforward: true
   creds:
     user: drupal
     password: drupal
     database: drupal
 drupal_site2:
   type: mysql
   portforward: true
   creds:
     user: drupal_site2
     password: drupal_site2
     database: drupal_site2
 search:
   type: solr:7
   portforward: true
   core: drupal9
   config:
     dir: docroot/modules/contrib/search_api_solr/jump-start/solr7/config-set
 memcache:
   type: memcached:1.5.11
   portforward: false
   mem: 64
 pma:
   type: phpmyadmin
   hosts:
     - drupal
     - drupal_site2
 mailhog:
   type: mailhog:v1.0.0
   portforward: false
   hogfrom:
     - appserver
 appserver:
   build_as_root:
     - apt-get update
     - apt-get install libxss1
     - echo "Run additional build commands here. Run lando rebuild after updating this file."
     - curl -sL https://deb.nodesource.com/setup_16.x | bash -
     - apt update && apt-get install -y nodejs && npm install -g gulp yarn
     - apt-get install -y python2.7 && ln -s /usr/bin/python2.7 /usr/bin/python2 && ln -s /usr/bin/python2 /usr/bin/python
   build:
     - composer install
     - echo "Installing core dependencies."
     - yarn install --non-interactive --cwd /app/docroot/core
   overrides:
     environment:
       DRUPAL_TEST_BASE_URL: 'https://site1.lndo.site'
       DRUPAL_TEST_DB_URL: 'mysql://drupal:drupal@drupal:3306/drupal'
       DRUPAL_TEST_WEBDRIVER_HOSTNAME: chromedriver
       DRUPAL_TEST_WEBDRIVER_PORT: 9515
       DRUPAL_TEST_CHROMEDRIVER_AUTOSTART: 'false'
       DRUPAL_TEST_WEBDRIVER_CHROME_ARGS: --headless --no-sandbox --ignore-certificate-errors --allow-insecure-localhost
       DRUPAL_NIGHTWATCH_OUTPUT: reports/nightwatch
       DRUPAL_NIGHTWATCH_IGNORE_DIRECTORIES: node_modules,vendor,.*,sites/*/files,sites/*/private,sites/simpletest
 chromedriver:
   type: compose
   services:
     image: drupalci/chromedriver:production
     expose:
        - "9515"
     command: ["chromedriver", "--verbose", "--allowed-ips=", "--allowed-origins=*"]
tooling:
 drupal:
   service: appserver
   description: Runs drupal console commands.
 blt:
   service: appserver
   cmd: /app/vendor/bin/blt
 drush:
   service: appserver
   cmd: /app/vendor/bin/drush
   dir: /app/docroot
 composer:
   dir: /app
 xdebug-on:
   service: appserver
   description: Enable xdebug for Apache.
   cmd: docker-php-ext-enable xdebug && service apache2 reload
   user: root
 xdebug-off:
   service: appserver
   description: Disable xdebug for Apache.
   cmd: rm /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini && service apache2 reload
   user: root
 phpunit:
   service: appserver
   cmd: /app/vendor/bin/phpunit
   description: Run phpunit.
 nightwatch:
   service: appserver
   description: Run Nightwatch.js
   cmd: yarn test:nightwatch
   dir: /app/docroot/core
 yarn:
   service: appserver
   cmd: yarn

There are multiple errors I'm getting

1st error - PHP Fatal error: Uncaught ValueError: Path cannot be empty in /app/docroot/core/tests/Drupal/TestTools/PhpUnitCompatibility/PhpUnit8/ClassWriter.php:58

2nd error - Error while running .executeScript() protocol action: An unknown error has occurred – <unknown>: Failed to read the 'localStorage' property from 'Window': Storage is disabled

3rd error - Error while running .navigateTo() protocol action: An unknown server-side error occurred while processing the command. – unknown error: session deleted

Jaswin Singh avatar
jm flag
I was able to solve the few of the issues as phpunit was not added in vendors directory. I have to manually add the PHPUnit to root composer.json file. But some of the error still exists like `Failed to read the 'localStorage' property from 'Window': Access is denied` and `An error occurred while executing user supplied JavaScript. – javascript error: Drupal is not defined`
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.