tyler36 / ddev-cypress

Cypress E2E testing for use with DDEV
Apache License 2.0
11 stars 8 forks source link

Add Mac OS guidance to the README #38

Open UltraBob opened 4 months ago

UltraBob commented 4 months ago

I had some trouble getting set up on the mac. Now that I've figured out how to get it up and going, I thought it would be useful to provide those steps to others.

tyler36 commented 4 months ago

@UltraBob Thank you for the PR.

The PR seems reasonable.

When someone else can confirm this works (thank you @rfay ) and the feedback is address, I'm happy to merge.

mandrasch commented 4 months ago

Nice @UltraBob, thanks for providing!

I tried to quickly test it and got the following on OSX Ventura 13.5.2 after installing with brew and allowing all connections.

/~ % xhost + 127.0.0.1
zsh: command not found: xhost

I added this to my ~/.zshrc file and used source ~/.zshrc:

export X11_PATH="/opt/X11/bin"
export PATH=$X11_PATH:$PATH

Afterwards I got

/bin % xhost + 127.0.0.1
xhost:  unable to open display ""
rfay commented 4 months ago

Don't you have to install and run an X server on the Mac?

With any X setup the first thing to do is just try to run a trivial app like xeyes.

mandrasch commented 4 months ago

Don't you have to install and run an X server on the Mac?

With any X setup the first thing to do is just try to run a trivial app like xeyes.

I installed brew install xquartz --cask and ran it with open -a Xquartz - like this PR suggested? 🤔

rfay commented 4 months ago

I will make some time to fiddle with this. Sorry for the uninformed comment.

UltraBob commented 4 months ago

@mandrasch are you running that last command xhost +127.0.0.1 on your Mac? My understanding is that that is where it needs to be run. I discovered that for my case cypress running in a separate container was not what I wanted, so I unfortunately don't have my working config for this setup to examine anymore. That said, it seems like the same concepts should apply, so hopefully we can get this worked out together.

If you want to be sure XQuartz will accept connections from anywhere, beyond the XQuartz settings, I believe xhost + should disable access control which is likely useful while trying to establish connections.

mandrasch commented 4 months ago

@rfay now worries! :)

@UltraBob Yes, on my mac - in my terminal.

Interestingly it seems that a reboot is needed. It now works after I restarted my Mac ✅

open -a Xquartz
xhost +127.0.0.1 
127.0.0.1 being added to access control list

image

mandrasch commented 4 months ago

image

Wow, works! 🎉 👍

After closing I needed to run the xhost command again, otherwise I'll get

Authorization required, but no authorization protocol specified

[1443:0624/204810.414864:ERROR:ozone_platform_x11.cc(240)] Missing X server or $DISPLAY
[1443:0624/204810.414871:ERROR:env.cc(255)] The platform failed to initialize.  Exiting.
UltraBob commented 4 months ago

Awesome! Let's add that bit about restarting after installing XQuartz into the README. I'm still running into that "Missing X server or $DISPLAY" error now that I've switched to cypress in the web container, and cannot for the life of me figure out what is wrong or different, but this does seem to work for the setup in this addon.

UltraBob commented 4 months ago

I've added a line about restarting.

tyler36 commented 4 months ago

So thats 2 confirmation of PR instructions for Mac?

UltraBob commented 4 months ago

I finally, with @rfay 's help, got it working on the web container, and can confirm the same steps work there if your global config hasn't somehow gotten borked in the interim between switching containers.

I put the restart instruction in the wrong place so I've edited that. I've also made the location for the extra config file more explicit, but I'd suggest adding the DISPLAY setting to the add-on, and removing the need for an extra file. It also seems @tyler36 as if the - /tmp/.X11-unix:/tmp/.X11-unix mount isn't required ... probably for any OS.

I understand the state to be two confirmations, but I can ask a colleague if they'd be willing to test on a Mac with the final instructions in place if you'd like?

tyler36 commented 4 months ago

@UltraBob
Thank you for the working through this. I've followed along with your discord threads and it's PRs like your future-you will really appreciate (as will everyone else)

I usually try and get 2 confirmations, especially for things like this that I can't confirm myself.

IIRC - /tmp/.X11-unix:/tmp/.X11-unix is required for my setup, on WSL, but I'll try and confirm.

tyler36 commented 2 months ago

Any updates here?

phenaproxima commented 4 weeks ago

This worked nicely for me to get Cypress running on macOS Sonoma.

In docker-compose.cypress.yml, DISPLAY=host.docker.internal:0, and I am running OrbStack.

XQuartz is installed and configured according to the updated instructions - the "allow all connections" thing was the clincher.

But once I did all that, ddev cypress-open actually managed to launch Cypress, which is super cool.