Mac/Jenkins: Cypress needs a logged in user to run headless tests
See original GitHub issueCurrent behavior:
Our Jenkins is started through LaunchDaemons as some specific user, which is not logged in, and therefore has no running windowserver (SystemUIServer
, or however this thing is called nowadays).
Jenkins then launches cypress run
, which fails with:
_RegisterApplication(), FAILED TO establish the default connection to the WindowServer, _CGSDefaultConnection() is NULL.
and later on:
BrowserWindow.getExtensions is not a function
TypeError: BrowserWindow.getExtensions is not a function
at Object.removeAllExtensions (/Users/Shared/Jenkins/Library/Caches/Cypress/4.4.0/Cypress.app/Contents/Resources/app/packages/server/lib/gui/windows.js:77:41)
...
This is the full log file.
I also noticed, when I am on my local machine, and do a cypress run
, it pops up a Dock icon, which only has a main menu with a single Quit item, and points to ~/Library/Caches/Cypress/4.6.0/Cypress.app
. I guess it shouldn’t do that either.
Workarounds
I found two workarounds:
- I switched from Electron to Chromium, and at least Chromium runs the tests, but cannot record vidoes.
- I logged in as the Jenkins user in the Console via Screen Sharing. Now Electron runs fine and does record videous. It also puts its icon into the Dock.
Desired behavior:
Cypress and Electron should not require a UI when running in headless mode.
To reproduce
- a Mac with two user accounts
- login as user A
- In Terminal:
sudo su - B
- as user B, run
cypress run
Strangely enough, in this case, simply logging in a user B as well does NOT fix the problem.
Versions
This applies to at least 4.40 - 4.6.0.
EDIT: 3.4.1 also does this, so this is NOT related to #7393
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (1 by maintainers)
Top GitHub Comments
Our workaround is to keep the Jenkins user permanently logged in via Screen Sharing… Which is something we need to remember, whenever we reboot the machine… 😉
This is still hitting us today. We haven’t found a workaround.