Minimal repro of cy.screenshot timeout/hang as discussed in issue 5016.
On Windows, cypress
test failures cannot take screenshots, instead, they timeout after 30 seconds (or, seen outside this repro, crash cypress w/error code 3221225477, evidently an access violation).
The timeout occurs frequently, but not 100% of the time.
This repo demonstrates the timeout:
CypressError: `cy.screenshot()` timed out waiting `30000ms` to complete.
...this also seems to prevent cypress from exiting normally.
- Windows
- Cypress 9.2.1 (and older, according to the aforementioned GH issue)
- headless mode
- built-in electron browser
- Node 12, 14, or 16
After installing the dependencies via npm i
, to run the demo, simply run npm start
.
This demo is created from the default "cypress" folder that a fresh installation gives you the first time you open cypress
. I removed the demo tests so there is only a single file repro.spec.js
that should be executed.
Please note that the cypress run
command here uses the recently released CYPRESS_VERIFY_TIMEOUT
env var as we have found that necessary to run cypress the first time on new machines.
- a simple
cy.screenshot()
call (not associated with a failure) will work, AND will prevent subsequent failing assertions from timing out on their screenshots (?) - enabling video, using a
cypress.json
config setting ofvideo
w/a value oftrue
will (oddly) prevent the timeouts, which I learned from the aforementioned GH issue, specifically this comment. - disabling failure screenshots altogether with a
cypress.json
config setting ofscreenshotOnRunFailure
w/a value offalse
will prevent the timeouts - if you enable
DEBUG=cypress:*
, the timeout occurs less frequently for some reason, but when/if it DOES timeout, you will see the last trace line before the timeout as
cypress:server:browsers:electron debugger: sending Page.captureScreenshot with params { format: 'png' }