mediacurrent/ci-tests

Scripts helpful for testing a Drupal site on a Continuous-Integration server, or locally.


README

This package provides a collection of helpful scripts for testing a Drupal site on a Continuous Integration (CI) server or locally.

Features ✨

This package includes the following example tests:

  • code-fixer.sh: PHP Code Beautifier and Fixer (PHP CS Fixer)
  • code-sniffer.sh: PHP CodeSniffer (PHPCS)
  • cypress/: Cypress End-to-End Testing
  • pa11y/pa11y-review.sh: Pa11y Accessibility Testing
  • phpunit.sh: PHPUnit (Unit & Kernel tests)
  • playwright/: Playwright End-to-End and Visual Regression Testing

Installation 💻

  1. Require the package using Composer:

    composer require mediacurrent/ci-tests
    
  2. Repository Configuration (if necessary):

    If the package is not found, you might need to add it to the repositories section of your composer.json:

    "repositories": [
        {
            "type": "vcs",
            "url": "git@bitbucket.org:mediacurrent/ci-tests.git"
        }
    ]
    
  3. Initialize Tests:

    Run the following script from your project's root directory to copy the example tests into your project:

    ./vendor/mediacurrent/ci-tests/scripts/tests-init.sh
    

    📝 Note: This script copies the ./vendor/mediacurrent/ci-tests/tests directory to ./tests. It will not overwrite any existing files in your ./tests directory.

Playwright UI Setup and Launch 🎭

To simplify setting up and launching the Playwright test runner UI, a helper script is provided. This script automates Node.js version management (via NVM), dependency installation (via pnpm), and launching the UI.

Prerequisites

  • NVM (Node Version Manager): Must be installed.
  • Git: Often used by NVM to install Node.js versions.
  • The tests-init.sh script (mentioned above) must have been run to copy the tests directory, including tests/playwright.

Running the Setup Script

Execute the script from your project's root directory:

./vendor/mediacurrent/ci-tests/scripts/setup-and-launch.sh

Alternatively, if you are already inside your project's tests/playwright directory:

../../vendor/mediacurrent/ci-tests/scripts/setup-and-launch.sh

The script will perform the following steps:

  1. Ensure you are using the correct Node.js version (as defined in tests/playwright/.nvmrc).
  2. Install project dependencies using pnpm inside tests/playwright.
  3. Launch the Playwright UI development server.

Follow the on-screen prompts. The UI will typically be available at the address shown in the terminal (e.g., http://localhost:9323 or similar, Playwright's default show-report port).

Credits 🙏