Skip to content

Instantly share code, notes, and snippets.

@colorfield
Last active February 10, 2021 09:40
Show Gist options
  • Save colorfield/38f560d3d3bffbbebc71e2c3bf49ab17 to your computer and use it in GitHub Desktop.
Save colorfield/38f560d3d3bffbbebc71e2c3bf49ab17 to your computer and use it in GitHub Desktop.
Cypress

Cypress & Drupal

  • Introduction - webinar
  • Scope of Cypress - comparison with PHPUnit
  • Minimal setup - for local test and CI integration
  • Basic commands
  • PHPStorm integration
  • Documentation

Agile, BDD and Cypress intro

Slides / webinar

  • Agile practices > Development practices > TDD
  • BDD

Scope

  • Test a site from the configuration
  • Fixtures for the content (PHPUnit @dataProvider)
  • Just as PHPUnit functional, setup a Drupal site
  • Can be wrapped in a module / custom modules or the project
  • Covers shadow DOM so works with progressive or full decoupling
  • E2E: what the user interacts with, so includes any kind of hooks or alteration

Minimal setup

Valid setup for Travis, CircleCI, ... In this case, the site can be installed from the configuration and cached.

Get Drupal

composer create-project drupal/recommended-project drupal

Require development packages and Cypress module

composer require --dev drupal/core-dev
composer require --dev drupal/cypress
cd web/modules/contrib/cypress
nvm use 14
yarn

Install the minimal profile and Cypress module

php web/core/scripts/drupal install minimal
drush en cypress -y

Start and run a test server

drush serve
drush cypress:run

Basic commands

drush cypress:[command]

  • run: run with the CLI
  • open: run with the GUI
  • list: list test suites
  • clear: clear Cypress caches

Limit run by

  • test suite: mytestsuite
  • directory, feature: mytestsuite:sub/folder, mytestsuite:sub/folder/Example.feature
  • tag: --tags "@COMPLETED and @WIP"

PHPStorm integration

Plugins: Cucumber.js, Gherkin

Documentation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment