Also there’s no way you can open your regular browser from cypress in devcontainer. Add following to your devcontainer docker compose and rebuild containers
I wanted to use cypress testing for my custom frappe app within devcontainers.
I have a mac and I installed xquartz and obtained the DISPLAY ip after running install_x11_deps.sh in my local environment.
I viewed the development.md file and docker-compose ui-tester service. But I am not able to understand what steps needs to be taken to enable this service.
How is the ui-tester service getting connected to the frappe-bench service?
I also referred gameplan repository to get some insights.
After installing cypress yarn package within the frontend service of the custom frappe app, when I try to run cypress run or cypress open, I am getting this error:
It looks like this is your first time using Cypress: 13.7.0
Your system is missing the dependency: Xvfb
Install Xvfb and run Cypress again.
Read our documentation on dependencies for more information:
https://on.cypress.io/required-dependencies
If you are using Docker, we provide containers with all required dependencies installed.
----------
Error: spawn Xvfb ENOENT
----------
Platform: linux-arm64 (Debian - 12)
Cypress Version: 13.7.0
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
I managed to solve this by running install_x11_deps.sh and setting the DISPLAY variable within shell.
NOTE
Use xquartz for enabling UI testing on macOS. Also enable Settings->Security->Allow connections from new clients
Then for the docker-compose, i used this:
version: "3.7"
services:
...
ui-tester:
# pass custom command to start Cypress otherwise it will use the entrypoint
# specified in the Cypress Docker image.
# also pass "--project <folder>" so that when Cypress opens
# it can find file "cypress.json" and show integration specs
# https://on.cypress.io/command-line#cypress-open
entrypoint: "cypress --project path/to/project open"
image: "docker.io/cypress/included:latest"
environment:
- SHELL=/bin/bash
# get the IP address of the host machine and allow X11 to accept
# incoming connections from that IP address
#IP=$(ipconfig getifaddr en0) #or mac or \
# IP=$($(hostname -I | awk '{print $1}') ) #for Ubuntu
#/usr/X11/bin/xhost + $IP
# then pass the environment variable DISPLAY to show Cypress GUI on the host system
#DISPLAY=$IP:0
- DISPLAY
volumes:
# for Cypress to communicate with the X11 server pass this socket file
# in addition to any other mapped volumes
- /tmp/.X11-unix:/tmp/.X11-unix
- ..:/workspace:z,cached
network_mode: "host"
After this, start the devcontainer and install cypress within your node environment.