Run Javascript tests against test Drupal site

Created on 29 February 2024, 9 months ago
Updated 15 March 2024, 9 months ago

Problem/Motivation

Our basic Behat setup doesn't yet support testing against a Drupal site. Furthermore, we'll probably need to add a bit of Javascript behaviour in this module. So we'll also want to be able to test via Selenium,.

📌 Task
Status

Fixed

Component

Miscellaneous

Created by

🇨🇦Canada ergonlogic Montréal, Québec 🇨🇦

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

Comments & Activities

  • Issue created by @ergonlogic
    • ergonlogic committed ff50d6cd on main
      Relates to #3424737: Add selenium-chrome service for Javascript testing.
      
    • ergonlogic committed 0ca544de on main
      #3424737: Move dev tooling into .local-dev directory, to get JS tests to...
  • Status changed to Fixed 9 months ago
  • 🇨🇦Canada ergonlogic Montréal, Québec 🇨🇦

    We were running into issues w/ Behat not being able to find Drupal. This appears to be due to the patterns that DrupalFinder is looking for (combinations of paths for composer.json and Drupal core). The underlying issue seems to be that `ddev poser` doesn't create a persistent Composer file that DrupalFinder needs.

    To work around this, I resuscitated an idea that's been kicking around in my head for a while now. I moved all the tooling (config for Composer, DDEV, Behat, Drumkit, etc.) into a .local-dev directory.

    We can then include a composer.json using the "project" type. This works the way that DrupalFinder expects. We then symlink in our project thusly:

    {
        "name": "workflow_required_by_state/local-dev",
        "description": "Local development site for developing Workflow Required by State.",
        "type": "project",
        "repositories": [
            {
              "type": "path",
              "url": "/opt/project"
            },
            {
                "type": "composer",
                "url": "https://packages.drupal.org/8"
            }
        ],
        "require": {
            "drupal/workflow_required_by_state": "@dev",
     [...]
    

    The path repository points to /opt/project, which is configured as a mount in .local-dev/.ddev/docker-compose.mounts.yaml:

    services:
      web:
        volumes:
        - "../..:/opt/project"
    

    Then we can point Behat (which runs inside the DDEV "web" container) like so:

    default:
      autoload:
        - "/opt/project/features/bootstrap"
      suites:
        default: &default
          paths:
            - "/opt/project/features"
          contexts:
            - FeatureContext
    [...]
    

    This works quite nicely to avoid polluting the contrib project root with a lot of dev/test tooling. It also removes any project-specific config from this tooling, which should make it much easier to template into new projects.

  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024