{"id":15480209,"url":"https://github.com/tyler36/ddev-cypress","last_synced_at":"2025-04-22T15:24:28.738Z","repository":{"id":37204487,"uuid":"473510790","full_name":"tyler36/ddev-cypress","owner":"tyler36","description":"Cypress E2E testing for use with DDEV","archived":false,"fork":false,"pushed_at":"2025-03-04T02:39:37.000Z","size":136,"stargazers_count":12,"open_issues_count":2,"forks_count":9,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-03-29T16:22:59.392Z","etag":null,"topics":["cypress","ddev-get","hacktoberfest","hacktoberfest2023"],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tyler36.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-03-24T08:05:47.000Z","updated_at":"2025-03-04T02:39:41.000Z","dependencies_parsed_at":"2024-10-25T04:40:48.895Z","dependency_job_id":"d2263cc3-0620-455a-bad0-c772ae3d514d","html_url":"https://github.com/tyler36/ddev-cypress","commit_stats":{"total_commits":33,"total_committers":5,"mean_commits":6.6,"dds":"0.33333333333333337","last_synced_commit":"d14870f82477ae165932cc19cd9f8a13d79f39bd"},"previous_names":[],"tags_count":9,"template":false,"template_full_name":"ddev/ddev-addon-template","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tyler36%2Fddev-cypress","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tyler36%2Fddev-cypress/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tyler36%2Fddev-cypress/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tyler36%2Fddev-cypress/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tyler36","download_url":"https://codeload.github.com/tyler36/ddev-cypress/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250265561,"owners_count":21402130,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cypress","ddev-get","hacktoberfest","hacktoberfest2023"],"created_at":"2024-10-02T04:41:10.160Z","updated_at":"2025-04-22T15:24:28.722Z","avatar_url":"https://github.com/tyler36.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# DDEV-cypress \u003c!-- omit in toc --\u003e\n\n[![tests](https://github.com/tyler36/ddev-cypress/actions/workflows/tests.yml/badge.svg)](https://github.com/tyler36/ddev-cypress/actions/workflows/tests.yml) ![project is maintained](https://img.shields.io/maintenance/yes/2026.svg)\n- [Introduction](#introduction)\n- [Requirements](#requirements)\n- [Steps](#steps)\n  - [Configure `DISPLAY`](#configure-display)\n    - [macOS](#macos)\n    - [Linux](#linux)\n    - [Windows 10](#windows-10)\n      - [Running DDEV on Win10 (not WSL)](#running-ddev-on-win10-not-wsl)\n  - [A note about the Cypress image](#a-note-about-the-cypress-image)\n- [Commands](#commands)\n  - [`cypress-open`](#cypress-open)\n  - [`cypress-run`](#cypress-run)\n- [Notes](#notes)\n- [Troubleshooting](#troubleshooting)\n  - [\"Could not find a Cypress configuration file, exiting\"](#could-not-find-a-cypress-configuration-file-exiting)\n  - [\"Unable to open X display.\"](#unable-to-open-x-display)\n\n## Introduction\n\n[Cypress](https://www.cypress.io/) is a \"complete end-to-end testing experience\". It allows you to write JavaScript test files that automate real browsers. For more details, see the [Cypress Overview](https://docs.cypress.io/guides/overview/why-cypress) page.\n\nThis recipe integrates a Cypress docker image with your DDEV project.\n\nThe main benefit is integration of Chrome and Firefox browsers out of the box, providing a known static state regardless of local OS or cloud CI/CS development. It also provides X11 display support for MacOS and Windows users, whereas this usually just works in Linux.\n\nThis addon:\n- provides Cypress without the need to install \u003ca href=\"https://nodejs.org\"\u003eNode.js\u003c/a\u003e\n- provides Firefox and Chromium out of the box, preconfigured for Cypress\n- configures your project's HTTPS site a base URL\n- provides helper commands for running Cypress GUI or in headless mode\n\nInstalling Cypress with favorite package manager works great locally. However, maintaining a consistent node and browser environments across teams, operating systrems, CI/CS development pipelines and cloud development spaces can become a challenge.\n\n\u003ca href=\"https://www.drupal.org/docs/develop/automated-testing/browser-testing-using-cypress\"\u003eBrowser testing using Cypress\u003c/a\u003e sets up Cypress for Drupal manually. For Linux users this could be easier, since X11 and Firefox are usually already present.\n\n## Requirements\n\n- DDEV \u003e= 1.19\n- Modern OS\n  - MacOS 10.9 and above (Intel or Apple Silicon 64-bit (x64 or arm64))\n  - Linux Ubuntu 12.04 and above, Fedora 21 and Debian 8 (x86_64 or Arm 64-bit (x64 or arm64))\n  - Windows 7 and above (64-bit)\n- Interactive mode requires a X11 server running on the host machine.\n\n## Steps\n\n- Install service\n\n  For DDEV v1.23.5 or above run\n\n  ```shell\n  ddev add-on get tyler36/ddev-cypress\n  ```\n\n  For earlier versions of DDEV run\n\n  ```shell\n  ddev get tyler36/ddev-cypress\n  ```\n\n  Then restart the project\n\n  ```shell\n  ddev restart\n  ```\n\n\u003e [!NOTE]\n\u003e If you change `additional_hostnames` or `additional_fqdns`, you have to re-run `ddev add-on get tyler36/ddev-cypress`\n\n- Run cypress via `ddev cypress-open` or `ddev cypress-run` (headless).\n\nWe recommend running `ddev cypress-open` first to create configuration and support files.\nThis addon sets `CYPRESS_baseUrl` to DDEV's primary URL in the `docker-compose.cypress.yaml`.\n\n### Configure `DISPLAY`\n\nTo display the Cypress screen and browser output, you must configure a `DISPLAY` environment variable.\n\n#### macOS\n\nddev Cypress Setup (Mac)\n\n```bash\n# Install XQuartz\nbrew install xquartz --cask\n\n# Run XQuartz\nopen -a Xquartz\n```\n\nIn the XQuartz preferences, go to the “Security” tab and make sure the “Allow connections from network clients” checkbox is checked.\n\nNow __restart your Mac__.  XQuartz will not properly be set to listen for X11 connections until you do this.\n\n```bash\n# Run the below command\nxhost + 127.0.0.1\n```\nAdd a file called `docker-compose.cypress_extra.yaml` with the following content to the .ddev directory: \n\n```yaml\nservices:\n  cypress:\n    environment:\n      - DISPLAY=host.docker.internal:0\n```\n#### Linux\n\nYou may need to set up access control for the X server for this to work. Install the xhost package (one is available for all distros) and run:\n\n```sh\nexport DISPLAY=:0\nxhost +\n```\n\n#### Windows 10\n\nIf you are running DDEV on Win10 or WSL2, you need to configure a display server on Win10.\nYou are free to use any X11-compatible server. A configuration-free solution is to install [GWSL via the Windows Store](https://www.microsoft.com/en-us/p/gwsl/9nl6kd1h33v3#activetab=pivot:overviewtab).\n\n##### Running DDEV on Win10 (not WSL)\n\n- Install [GWSL via the Windows Store](https://www.microsoft.com/en-us/p/gwsl/9nl6kd1h33v3#activetab=pivot:overviewtab)\n- Get you \"IPv4 Address\" for your \"Ethernet adapter\" via networking panel or by typing `ipconfig` in a terminal. The address in the below example is `192.168.0.196`\n\n```shell\n❯ ipconfig\n\nWindows IP Configuration\n\n\nEthernet adapter Ethernet:\n\n   Connection-specific DNS Suffix  . :\n   IPv4 Address. . . . . . . . . . . : 192.168.0.196\n   Subnet Mask . . . . . . . . . . . : 255.255.255.0\n   Default Gateway . . . . . . . . . : 192.168.0.1\n```\n\n- In your project `./docker-compose.cypress.yaml`, add the IPv4 address and `:0` (For example `192.168.0.196:0` ) to the display section under environment.\n\n```yaml\n    environment:\n      - DISPLAY=192.168.0.196:0\n```\n\n### A note about the Cypress image\n\nThis recipe uses the latest `cypress/include` image which includes the following browsers:\n\n- Chrome\n- Firefox\n- Electron\n\nBest practice encourages using a [specific image tag](https://github.com/cypress-io/cypress-docker-images#best-practice).\n\n- If you require a specific browser, update `image` in your `./.ddev/docker-compose.cypress.yaml`.\n- Available images and versions are available on the [cypress-docker-images](https://github.com/cypress-io/cypress-docker-images) page.\n\n## Commands\n\nCypress can run into 2 different modes: interactive and runner.\nThis recipe includes 2 alias commands to help you use Cypress.\n\nTo see Cypress in interactive mode, Cypress forward XVFB messages out of the Cypress container into an X11 server running on the host machine. Each OS has different options. Developers have reported success with the following:\n\n- Windows 10 / WSL users:\n  - [GWSL](https://opticos.github.io/gwsl/tutorials/manual.html) (via [Microsoft store](ms-windows-store://pdp/?productid=9NL6KD1H33V3))\n  - [VcXsrv](https://sourceforge.net/projects/vcxsrv/) (via [chocolatey](https://community.chocolatey.org/packages/vcxsrv#versionhistory)).\n- Mac users:\n  - [XQuartz](https://www.xquartz.org/). See [Running GUI applications using Docker for Mac](https://sourabhbajaj.com/blog/2017/02/07/gui-applications-docker-mac/).\n\n### `cypress-open`\n\nTo open cypress in \"interactive\" mode, run the following command:\n\n```shell\nddev cypress-open\n```\n\nSee [\"#cypress open\" documentation](https://docs.cypress.io/guides/guides/command-line#cypress-open) for a full list of available arguments.\n\nExample: To open Cypress in interactive mode, and specify a config file\n\n```shell\nddev cypress-open --config cypress.json\n```\n\n### `cypress-run`\n\nTo run Cypress in \"runner\" mode, run the following command:\n\n```shell\nddev cypress-run\n```\n\nSee [#cypress run](https://docs.cypress.io/guides/guides/command-line#cypress-run) for a full list of available arguments.\n\nExample: To run all Cypress tests, using Chrome in headless mode\n\n```shell\nddev cypress-run --browser chrome\n```\n\n## Notes\n\n- The dockerized Cypress *should* find any locally installed plugins in your project's `node_modules`; assuming they are install via npm or yarn.\n- Some plugins may require specific settings, such as environmental variables. Pass them through via command arguments.\n\n## Troubleshooting\n\n### \"Could not find a Cypress configuration file, exiting\"\n\nCypress expects a directory structures containing the tests, plugins and support files.\n\n- If the `./cypress` directory does not exist, it will scaffold out these directories, including a default `cypress.json` setting file and example tests when you first run `ddev cypress-open`.\n- Make sure you have a `cypress.json` file in your project root, or use `--config [file]` argument to specify one.\n\n### \"Unable to open X display.\"\n\n- This recipe forwards the Cypress GUI via an X11 / X410 server. Please ensure you have this working on your host system.\n\n**Contributed by [@tyler36](https://github.com/tyler36)**\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftyler36%2Fddev-cypress","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftyler36%2Fddev-cypress","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftyler36%2Fddev-cypress/lists"}