PHPackages                             kanopi/shrubs - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Testing &amp; Quality](/categories/testing)
4. /
5. kanopi/shrubs

ActiveCypress-support[Testing &amp; Quality](/categories/testing)

kanopi/shrubs
=============

 A set of default support commands to get you jumpstarted configuring Cypress for Drupal.

0.2.16(7mo ago)6312.6k↓38.6%1[2 PRs](https://github.com/kanopi/shrubs/pulls)2GPL-2.0-or-laterJavaScript

Since Jul 31Pushed 7mo ago13 watchersCompare

[ Source](https://github.com/kanopi/shrubs)[ Packagist](https://packagist.org/packages/kanopi/shrubs)[ Docs](https://github.com/kanopi/shrubs)[ RSS](/packages/kanopi-shrubs/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (1)Versions (26)Used By (2)

[![shrubs](https://private-user-images.githubusercontent.com/5177009/302045131-e0d0ed6e-7e08-43be-9c82-69119bb19ab5.svg?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NzUyNzk2MTgsIm5iZiI6MTc3NTI3OTMxOCwicGF0aCI6Ii81MTc3MDA5LzMwMjA0NTEzMS1lMGQwZWQ2ZS03ZTA4LTQzYmUtOWM4Mi02OTExOWJiMTlhYjUuc3ZnP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI2MDQwNCUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNjA0MDRUMDUwODM4WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9MGUxMmE0NzYyMDA1Y2Y1MDU1ZTBjNDdiMTQ4MjJmYjA0ZGE4ODg5Mjc2Njk5ZjJhOTJmN2ZkMjM4NzY2NTU4YSZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QifQ.AAmyGBVvaXVnYomayRVbrU0ei_gRbV1WXEDUEu1s80o)](https://private-user-images.githubusercontent.com/5177009/302045131-e0d0ed6e-7e08-43be-9c82-69119bb19ab5.svg?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NzUyNzk2MTgsIm5iZiI6MTc3NTI3OTMxOCwicGF0aCI6Ii81MTc3MDA5LzMwMjA0NTEzMS1lMGQwZWQ2ZS03ZTA4LTQzYmUtOWM4Mi02OTExOWJiMTlhYjUuc3ZnP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI2MDQwNCUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNjA0MDRUMDUwODM4WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9MGUxMmE0NzYyMDA1Y2Y1MDU1ZTBjNDdiMTQ4MjJmYjA0ZGE4ODg5Mjc2Njk5ZjJhOTJmN2ZkMjM4NzY2NTU4YSZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QifQ.AAmyGBVvaXVnYomayRVbrU0ei_gRbV1WXEDUEu1s80o)

Shrubs (Drupal Cypress Support Commands)
========================================

[](#shrubs-drupal-cypress-support-commands)

Common support commands for Cypress when interacting with Drupal.

*Table of Contents*

- [Requirements](#requirements)
- [Installation](#installation)
- [Available Commands](#available-commands)
- [Issues](#issues)
- [Maintainers](#maintainers)

Requirements
------------

[](#requirements)

- Cypress installed on your local or CI.
- @TODO Document how we have Cypress set up.

Installation
------------

[](#installation)

### Install/update composer installers.

[](#installupdate-composer-installers)

Add two entries in composer.json for an install-type and its path:

```
"installer-types": ["cypress-support"],
"installer-paths": {
 // existing entries omitted...
 "tests/cypress/cypress/support/{$name}": [
   "type:cypress-support"
 ]
}

```

### Tell Cypress where to import the tests

[](#tell-cypress-where-to-import-the-tests)

In the `support` folder for where your Cypress tests are located, edit `commands.js` and add the following:

```
// Import commands.js using ES2015 syntax:
import './shrubs/commands'

```

### Requiring Shrubs using Composer

[](#requiring-shrubs-using-composer)

The Shrubs repository is available via Packagist.

Once you have completed the steps above, run the following command:

`composer require kanopi/shrubs`

### Update your CI process to...

[](#update-your-ci-process-to)

@TODO (See what Paul did on Parks)

Available Commands
------------------

[](#available-commands)

### Drupal Cypress autocomplete

[](#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

[](#drupal-cypress-ckeditor-get)

Gets the value of a ckeditor instance.

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

```

### Drupal Cypress ckEditor type

[](#drupal-cypress-ckeditor-type)

Set the value of a ckeditor instance.

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

```

### Drupal Cypress drush

[](#drupal-cypress-drush)

Runs Drush commands in multiple environments. With the correct configuration it can target the following:

- Docksal
- Lando
- DDEV
- Pantheon
- Tugboat

```
cy.drush('status');

```

#### Config examples

[](#config-examples)

Set these as environment variables or in your cypress.env.json **Docksal**

```
{
  "DRUSH_IS_DOCKSAL" : true
}
```

**Lando**

```
{
  "DRUSH_IS_LANDO" : true
}
```

**DDEV**

```
{
  "DRUSH_IS_DDEV" : true
}
```

**Pantheon**

In the format of `PANTHEON_SITE_ID.ENVIRONMENT_ID`

```
{
  "DRUSH_IS_PANTHEON" : "mysite.pr-123"
}
```

**Tugboat**

- `DRUSH_IS_TUGBOAT` is your [Tugboat token](https://docs.tugboatqa.com/tugboat-cli/set-an-access-token/index.html)
- `TUGBOAT_INSTANCE_ID` is the ID of the specific Tugboat instance that is targeted [$TUGBOAT\_PREVIEW\_ID](https://docs.tugboatqa.com/reference/environment-variables/index.html#image-specific-variables)

```
{
  "DRUSH_IS_TUGBOAT" : "12345abcdef",
  "TUGBOAT_INSTANCE_ID" : "1234567890"
}
```

##### Tugboat CLI

[](#tugboat-cli)

The Tugboat CLI needs a little extra help being installed in AMD64 architecture. For example if you are install the CLI within a CI/CD system like CircleCI or GitHub Actions.

```
sudo dpkg --add-architecture amd64
sudo apt-get update
sudo apt-get install libc6:amd64 libstdc++6:amd64
wget https://dashboard.tugboatqa.com/cli/linux/tugboat.tar.gz
sudo tar -zxf tugboat.tar.gz -C /usr/local/bin/
```

### Drupal Cypress login

[](#drupal-cypress-login)

Login through the default Drupal login form. 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 login as a specific user

[](#drupal-cypress-login-as-a-specific-user)

Uses a Drush one time login links to login as a specific user.

```
cy.loginOneTimeLink('myusername');

```

### Drupal Cypress logout

[](#drupal-cypress-logout)

Logs out of the current session

```
cy.logout();

```

### Ajax Click

[](#ajax-click)

There a clicks that can generate a blocking ajax request. I.E. Opening modals or slideouts that load content with an ajax request.

The function will wrap an intercept/wait combination around the click to make sure the tests don't continue until the ajax request as completed.

It's also meant to deal with the anti-pattern of using [wait()](https://docs.cypress.io/guides/references/best-practices#Unnecessary-Waiting) for clicks that trigger ajax requests.

**Example**

```
cy.ajaxClick("a.product-name", '/jsonapi/*/**')

```

This replaces code that would look like this.

```
const jsonApiRequest5 = 'jsonApiRequest' + Math.random();
cy.intercept('GET', '/jsonapi/*/**').as(jsonApiRequest5)
cy.get('a.product-name').click();
cy.wait('@' + jsonApiRequest5).its('response.statusCode').should('eq', 200)

```

or

```
cy.get('a.product-name').click();
cy.wait(5000)

```

### Drupal Cypress add item to media library

[](#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

[](#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

[](#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');`

```

### logAndStore(message)

[](#logandstoremessage)

Logs a message and stores it in an internal array to be retrieved later using `cy.logSummary();`

```
cy.logAndStore('This is a log message.');

```

### logSummary()

[](#logsummary)

Outputs all stored log messages at the end of a test run.

```
cy.logSummary();

```

Example with after() Hook

```
describe('Example Test with log summary', () => {
  beforeEach(() => {
    cy.visit('/example-page');
  });

  it('should log multiple steps', () => {
    cy.logAndStore('Step 1: Visiting the page.');
    cy.logAndStore('Step 2: Clicking a button.');
    cy.logAndStore('Step 3: Validating output.');
  });

  after(() => {
    cy.logSummary();
  });
});

```

Pantheon interstitial page and Cypress tests
--------------------------------------------

[](#pantheon-interstitial-page-and-cypress-tests)

In May 2025 [Pantheon added an Interstitial page](https://docs.pantheon.io/release-notes/2025/05/interstitial-pages) to projects that are at the Sandbox level. Kanopi has the following work around of overwriting the `visit()` command.

In `e2e.js`

```
/**
 * Overwrite the visit() command to support setting headers globally.
 */
Cypress.Commands.overwrite("visit", (originalVisit, url, options = {}) => {
  const globalHeaders = Cypress.env('visitHeaders') || {};

  // Combine global and specific headers from the unique call of visit().
  const headers = Object.assign({}, globalHeaders, options.headers);

  // Call the real visit with the merged headers
  return originalVisit(url, { ...options, headers });
});
```

In your `cypress.config.js` you can add the following environment variable.

```
env: {
  "visitHeaders" : {
    "Deterrence-Bypass" : "1"
  }
}
```

Now when the `visit()` command is done you dont have to worry about a cookie being set prior.

If you want to set the cookie to bypass the page later you can do so with.

```
cy.setCookie("Deterrence-Bypass", "1");
```

Issues
------

[](#issues)

For issues and support, please use the issue queue at

Maintainers
-----------

[](#maintainers)

Current maintainers:

- [thejimbirch](https://www.drupal.org/u/thejimbirch)
- [paulsheldrake](https://www.drupal.org/u/paulsheldrake)

This project is sponsored by:

- [Kanopi studios](https://www.drupal.org/kanopi-studios)

###  Health Score

44

—

FairBetter than 92% of packages

Maintenance62

Regular maintenance activity

Popularity41

Moderate usage in the ecosystem

Community23

Small or concentrated contributor base

Maturity44

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 52.8% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~35 days

Recently: every ~97 days

Total

23

Last Release

233d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/bf9dca5c46910be861bb00920034637b5a36a1f6277413be6817a50a1ce6fc74?d=identicon)[kanopi\_studios](/maintainers/kanopi_studios)

---

Top Contributors

[![thejimbirch](https://avatars.githubusercontent.com/u/5177009?v=4)](https://github.com/thejimbirch "thejimbirch (65 commits)")[![paulsheldrake](https://avatars.githubusercontent.com/u/1062456?v=4)](https://github.com/paulsheldrake "paulsheldrake (40 commits)")[![Stockfoot](https://avatars.githubusercontent.com/u/36280534?v=4)](https://github.com/Stockfoot "Stockfoot (12 commits)")[![asipple1](https://avatars.githubusercontent.com/u/4413018?v=4)](https://github.com/asipple1 "asipple1 (2 commits)")[![oliverharrison](https://avatars.githubusercontent.com/u/18194487?v=4)](https://github.com/oliverharrison "oliverharrison (1 commits)")[![nkarhoff](https://avatars.githubusercontent.com/u/45244877?v=4)](https://github.com/nkarhoff "nkarhoff (1 commits)")[![nathan-stone-kanopi](https://avatars.githubusercontent.com/u/127078235?v=4)](https://github.com/nathan-stone-kanopi "nathan-stone-kanopi (1 commits)")[![delaneyceo](https://avatars.githubusercontent.com/u/524757?v=4)](https://github.com/delaneyceo "delaneyceo (1 commits)")

---

Tags

cypressdo-not-archivedrupalinternal-tooltestingautomationdrupale2ecypresssupport-commandscypress.iointegration-test

### Embed Badge

![Health badge](/badges/kanopi-shrubs/health.svg)

```
[![Health](https://phpackages.com/badges/kanopi-shrubs/health.svg)](https://phpackages.com/packages/kanopi-shrubs)
```

###  Alternatives

[symfony/panther

A browser testing and web scraping library for PHP and Symfony.

3.1k14.7M96](/packages/symfony-panther)[magento/magento2-functional-testing-framework

Magento2 Functional Testing Framework

15511.5M30](/packages/magento-magento2-functional-testing-framework)[zoon/puphpeteer

A Puppeteer bridge for PHP, supporting the entire API.

204192.9k1](/packages/zoon-puphpeteer)[acquia/orca

A tool for testing a company's software packages together in the context of a realistic, functioning, best practices Drupal build

32902.4k](/packages/acquia-orca)[nearsoft/php-selenium-client

This library allows creating Selenium Server V2 tests in PHP. It communicates with the WebDriver API through the official JsonWireProtocol.

10854.9k](/packages/nearsoft-php-selenium-client)[playwright-php/playwright

Modern PHP library for Playwright automation: browsing, scraping, screenshots, testing, and more.

7613.0k5](/packages/playwright-php-playwright)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
