Running Cypress in headless mode using Electron does not center page when autoscaling
See original GitHub issueCurrent 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)
- Write some tests that involves clicking on a button that potentially might be off screen
- 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:
- Created 4 years ago
- Comments:5 (3 by maintainers)
Top GitHub Comments
@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.
@jennifer-shehane
Actually! This was because in the config, viewport
height
andwidth
needs to beint
instead ofstring
.Example:
Not sure if this needs to be made more clear anywhere in the docs.