Common support commands for Cypress when interacting with Drupal to help you write consistent tests faster.

Code and development happen at https://github.com/kanopi/shrubs

Please use the issue queue on Drupal.org.

Installation

Configure your Drupal instance first using the instructions in https://github.com/kanopi/shrubs/blob/main/README.md

Then install using Packagist:

composer require kanopi/shrubs

Available Commands

Drupal Cypress autocomplete

Will select the first match from an autocomplete field.

cy.autocomplete('input[data-drupal-selector="edit-field-episode-show-0-target-id"]', 'Term Name')

Drupal Cypress ckEditor get

Gets the value of a ckeditor instance.

cy.ckeditorGet('#edit-body-wrapper').should('contain', 'hello world')

Drupal Cypress ckEditor set

Set the value of a ckeditor instance.

cy.ckeditorSet('#field_body-wrapper', 'hello world');

Drupal Cypress drush

Runs Drush commands in multiple environments

Support running commands against Pantheon multidev environments as well.

cy.drush('status');

Drupal Cypress login

Sets a default login but also passing custom login details

cy.login(); // login as a default user.   
cy.login('user', 'password'); // as a specific user

Assuming there is some other process to create the user.

Drupal Cypress logout

Logs out of the current session

cy.logout();

Drupal Cypress add item to media library

Uploads a file to the media library and selects it in the field.

Can optionally set the type of media uploaded if there is more than one type available.

Files are expected to be in the fixtures folder at the same level as support and e2e. In most cases, that will be /tests/cypress/cypress/fixtures.

cy.mediaLibraryAdd('#field_media_assets-media-library-wrapper', 'sample.png');
cy.mediaLibraryAdd('#field_media_assets-media-library-wrapper', 'sample.mp3', 'audio');

Drupal Cypress select item in the media library

Open a media browser modal and selects an existing media item

Can optionally set the type of media uploaded if there is more than one type available.

Files are expected to be in the fixtures folder.

cy.mediaLibrarySelect('#field_media_assets-media-library-wrapper', 'sample.png');
cy.mediaLibrarySelect('#field_media_assets-media-library-wrapper', 'sample.png', 'image');

Drupal Cypress upload file

Upload a file through a file field Files should be in the fixtures folder.

cy.uploadFile('#file-field-wrapper', 'example.png');`
Supporting organizations: 

Project information

  • Created by thejimbirch on , updated
  • shieldStable releases for this project are covered by the security advisory policy.
    There are currently no supported stable releases.

Releases