question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Mac/Jenkins: Cypress needs a logged in user to run headless tests

See original GitHub issue

Current 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:open
  • Created 3 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
marc-guenthercommented, Aug 24, 2020

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… 😉

0reactions
jesseadamscommented, Nov 17, 2021

This is still hitting us today. We haven’t found a workaround.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to run tests in headless mode with Cypress
The good news is that in addition to being powerful, Cypress is a simple tool. To run the tests in headless mode, use...
Read more >
Launching Browsers | Cypress Documentation
When you run tests in Cypress, we launch a browser for you. This enables us to: Create a clean, pristine testing environment. Access...
Read more >
How To Run Cypress Tests In Headless Mode - YouTube
Watch this video to learn how to run Cypress tests in headless mode differently. Start FREE Testing : ...
Read more >
Running Cypress Tests in Headless Mode - Applitools
With its framework, we're able to run commands that test our applications directly in the same browsers that our users are using them...
Read more >
Cypress not re-using cookies or session in headless mode
I think the cy.session() wrapped code needs to be called from every spec. Did you try spec2 with a call to cy.login() ?...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found