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.

Running Cypress in headless mode using Electron does not center page when autoscaling

See original GitHub issue

Current behavior:

When running Cypress using: cypress run --env environment=xxx - Autoscaling does not center the website which causes certain tests to fail when elements are off screen during headless mode.

Note 1: This passes when using cypress open --env environment=xxx Note 2: Both times tests were triggered using Electron 59 running Cypress 3.1.4

I came to this conclusion because the screenshot when using run shows that it’s at 57% scale and the image is off screen. However, when I run the test with open and resize it to 57%, I can see that the page would shift after <1s and center the page.

Desired behavior:

Autoscaling works properly when using cypress run

Steps to reproduce: (app code and test code)

  1. Write some tests that involves clicking on a button that potentially might be off screen
  2. Run the test with cypress run using Electron 59

Result: Page will not center during autoscaling

Expected: Page will center during autoscaling

Versions

Cypress 3.1.4 Electron 59 MacOS 10.14.5

Note: This might be an isolated issue with the newest Macbook Pro (2018) and MacOS 10.14.5 since the tests are fine in CI running the same command.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
jennifer-shehanecommented, Jul 15, 2019

@hvuong-sigma K, you may want to look into setting up configuration with our schema file to avoid this from happening again.

Although, it may be nice for us to just accept string values and coerce them in this situation.

0reactions
hvuong-sigmacommented, Jul 11, 2019

@jennifer-shehane

Actually! This was because in the config, viewport height and width needs to be int instead of string.

Example:

  "viewportHeight": 900,
  "viewportWidth": 1440,

Not sure if this needs to be made more clear anywhere in the docs.

Read more comments on GitHub >

github_iconTop Results From Across the Web

viewport | Cypress Documentation
Auto Scaling. By default, if your screen is not large enough to display all of the current dimension's pixels, Cypress will scale and...
Read more >
How To Run Cypress Tests In Headless Mode - YouTube
It is a version of Chromium that comes with the Electron framework. ... How do you run a test in Cypress in headless...
Read more >
A Quick Overview Of Running Cypress Tests in Headless Mode
This test automation recipe will show you how to run your Cypress tests in headless mode, including the default Electron browser, Chrome, ...
Read more >
Running Cypress Tests in Headless Mode - Applitools
So, we can run our tests headlessly, where if we're running our default Cypress settings with the Electron browser, we can simply run...
Read more >
How to Debug Cypress Tests : Tutorial | BrowserStack
Start debugging your Cypress tests on real browsers. ... console.log() can be used with both headless mode (command-line) and headful mode ...
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