Cypress slows down drastically over long runs - restart renderer between spec files?
See original GitHub issueDescription
When I try to run all tests at once with cypress run
, the tests slow down part-way through. I think this is related to the memory usage of the renderer, since a process called ‘Cypress helper’ has a continuously increasing memory usage, and the slowdown hits when it reaches 3 to 3.5GB of RAM (I only have 4GB on my system). Eventually, a test that usually takes 10-15 seconds took over 3 minutes to run.
I’m running the tests locally on a MacBook, using Cypress CLI 0.13.1 and App 0.19.0.
Additional Info
As suggested in issue #349, I think an option like restartBrowserBetweenSpecFiles: true
in cypress.json would most likely fix the issue for me.
Not many options seem to help the memory usage much, turning off video recording and setting number of tests kept in memory to 0 probably made it last a little bit longer, but it’s not the Cypress process itself that is using all the memory.
CYPRESS_MEMORY=1 /Applications/Cypress.app/Contents/MacOS/Cypress --project <path_to_your_project> --show-headless-gui
Brian suggested running the above command to view the memory usage for the node process, but the value reported never went over 100MB so I doubt there’s any problem here. For reference, the output in the terminal looked like this: info { rss: 132407296, heapTotal: 102604800, heapUsed: 89873952 }
Issue Analytics
- State:
- Created 7 years ago
- Reactions:7
- Comments:34 (14 by maintainers)
Top GitHub Comments
Hi @brian-mann , I’m just scratching the surface of Cypress but i would appreciate if any of you could help me with the following situation: 1- Within my app, once a certain button is clicked, a spinner is triggered and once it’s done a page with a modal (which has a read-only text area) and i’m trying to grab a
!DOCTYPE html PUBLIC
using contain(cy.get('.modal-wrapper').contains('!DOCTYPE html PUBLIC');)
being.modal-wrapper
a class active within that modal… So in my attempt to get to this modal i didBut after clicking that button i get CypressError:
Timed out retrying: Expected to find element: '.modal-wrapper', but never found it.
and then i keep gettingBut my test never gets to assert that the text I’m looking for does exist, cypress never gets to that point in my app (and it’s working ok)
Any help would be very much appreciated, apologies in advance this is my very first post and I’m not a natural speaker.
Thanks a lot
No. We definitely do not run anything from the GUI.
The GUI isn’t meant to run entire test suites. It’s meant to be used in your day to day development typically on a single test file or maybe just a few.
The GUI is not optimized for long runs, only headless is.
For instance
numTestsKeptInMemory
by default is 50 for headed runs. This essentially keeps every single DOM snapshot for every single command for tests up to 50 in memory. That’s why the headed browser will eventually slow down.This configuration option is automatically set to
0
when running headlessly. There are also lots of internal optimizations because when you’re running headlessly you cannot interact with the test results. For instance, we don’t even take DOM snapshots when running headlessly.So… all of what I said above was about headless runs. If you’re trying to use the GUI for this, it definitely won’t work and likely won’t ever work for all of these reasons.
I thought you were having problems running headlessly (?)