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.

Run Cypress Headless Without Binary

See original GitHub issue

Current behavior:

npm install cypress downloads the cypress app binary

Desired behavior:

npm install cypress (or something like npm install @cypress/headless) does not install a binary, and only installs necessary dependencies for running tests headlessly on CI.

Additional Info (images, stack traces, etc)

Our CI configuration is pretty strict about what can be externally downloaded. It would be great if cypress could be run without needing to whitelist the cypress domain.

  • Operating System: Linux centos
  • Cypress Version: 1.4.1
  • Browser Version: Chrome 63

Issue Analytics

  • State:open
  • Created 6 years ago
  • Reactions:14
  • Comments:84 (10 by maintainers)

github_iconTop GitHub Comments

14reactions
brian-manncommented, Jun 1, 2018

This is something we’ve internally talked a lot about and I have a lot of notes for. It is possible to do this - you wouldn’t be able to run Electron, but you would be able to spawn an external browser.

The problem comes in where you have conflicting packages. You’d likely check in cypress already for local development and wouldn’t want that to npm install in CI, and you also wouldn’t want to check in a separate packaged like @cypress/headless.

For this to work I think we’d just need to set an env var like: CYPRESS_INSTALL_BINARY=0 which avoids installing the binary and the CLI would have to be upgraded to run in your node environment as opposed to always expecting the binary to exist. This would then run Cypress in your node environment (which is another can of worms) but it would work.

EDIT: another advantage of this is that if we supported Chrome headless (which we will), this avoids the need to orchestrate or have xvfb installed - since Electron would not need spawning locally. This creates a bit of combinatory explosion since it would require a lot of explaining and documentation, but that’s another upside to this method.

12reactions
WinstonNcommented, Dec 19, 2019

Hello, I am reviving this issue ❤️

Since the launch of cypress 3.8.0 we now have the ability to run cypress --headless - which is really cool

I’ve been trying to run cypress in a lambda function, and I have a few questions, which I am hoping someone here could help me with

At first I thought I would be clever, and check in my node_modules into source control, then bring this into a lambda and execute cypress from there, but it didn’t work out that well because I got this output, which I didn’t expect

Cypress package version: 3.8.0
Cypress binary version: not installed

The cypress binary was a curious one, and I started digging deeper from there

I saw that Cypress saves this binary, in the user’s cache directory - as below (taken from a ubuntu 18.04 virtualbox install)

image

I then tried to bring Cypress into my lambda function via a lambda layer (https://docs.aws.amazon.com/lambda/latest/dg/configuration-layers.html) but I quickly ran into size issues

  Serverless Error ---------------------------------------

  An error occurred: RunLambdaFunction - Function code combined with layers exceeds the maximum allowed size of 262144000 bytes. The actual size is 274082977 bytes. (Service: AWSLambdaInternal; Status Code: 400; Error Code: InvalidParameterValueException; Request ID: aaa9ecec-2cbf-43b8-837e-777).

This got me onto looking at the size of Cypress, in it’s entirety

Below are the sizes of directories, in the home directory cache folder for Cypress, that are 1MB and bigger

image

404MB is taken up by resources/app/packages/ of which 257MB is server node_modules

image

and below is the same stats from the node_modules folder

image

which means that pretty much the entire Cypress size comes from

cypress binary 111MB resources/app/packages 404MB

My questions are

  1. If I don’t want to record tests, or use the graphical UI of cypress at all, what can I remove from these folders to bring the size down? Is that even possible?
  2. Inline with the question above, how do I “build” cypress after removing these? Is there some contributors documentation that will help me answer the technical bits
  3. I can already run chrome headless in lambda, and looking at this documentation (https://docs.cypress.io/guides/guides/launching-browsers.html#Customize-available-browsers) it should be possible to setup/add new browsers, and specify their paths. My question is, how do I run cypress with these browsers in the command line? That documentation only cover the graphical bit

And in closing, I just want to say, wow man, wow! You’ve built something so amazing an pretty and functional here, and I am so blown away by the quality of it all

Thank you for every little bit of effort you put into cypress because it’s really such a wonderful product

Read more comments on GitHub >

github_iconTop Results From Across the Web

Command Line - Cypress Documentation
This matches how you run any browser via cypress open . cypress run --headed. cypress run --no-exit. To prevent Cypress from exiting after...
Read more >
Introduction | Cypress Documentation
Run the binary install yourself by adding the command npx cypress install to your CI script. If there is a binary already present,...
Read more >
Launching Browsers | Cypress Documentation
Launching by a path. You can launch any supported browser by specifying a path to the binary: cypress run --browser /usr/bin/chromium.
Read more >
Installing - Cypress Documentation
When running Cypress in CI, however, some of the lower-tier configurations might not be able to run Cypress reliably, especially when recording videos...
Read more >
Troubleshooting | Cypress Documentation
Run the same tests in both Electron and Chrome, then compare the ... If this does not succeed, it will fall back to...
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 Hashnode Post

No results found