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.

Cypress slows down drastically over long runs - restart renderer between spec files?

See original GitHub issue

Description 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:closed
  • Created 7 years ago
  • Reactions:7
  • Comments:34 (14 by maintainers)

github_iconTop GitHub Comments

16reactions
L4mPi2commented, Sep 5, 2018

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 did

describe('Hitting Complete email button', function() {
  it("Completes your email", function() {

    cy.contains('Complete')
      .click()
    cy.get('.modal-wrapper').contains('!DOCTYPE html PUBLIC');
  });
});

But after clicking that button i get CypressError: Timed out retrying: Expected to find element: '.modal-wrapper', but never found it. and then i keep getting

(XHR)
POST 403 /campaign/spent-time
(XHR)
POST 403 /campaign/lock
(XHR)
POST 403 /campaign/spent-time
(XHR)
POST 403 /campaign/lock
(XHR)
POST 403 /campaign/spent-time
(XHR)
POST 403 /campaign/lock
(XHR)
POST 403 /campaign/spent-time  

But 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

9reactions
brian-manncommented, Mar 7, 2017

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 (?)

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cypress slows down drastically over long runs - Bountysource
Cypress slows down drastically over long runs - restart renderer between spec files?
Read more >
Troubleshooting | Cypress Documentation
Open Cypress via cypress open · Go to Developer Tools -> View App Data · This will take you to the directory in...
Read more >
cypress-io/cypress - Gitter
from last 2 day I am not able to run any test-case on chrome. ... Cypress slows down drastically over long runs -...
Read more >
End-to-End Testing | Gatsby
run method under the hood. This method can slow down Cypress and make the window unresponsive if you have a lot of elements...
Read more >
Slow Down Cypress Tests - YouTube
This video shows how to slow down a Cypress test by adding a delay to every Cypress command in the test using the...
Read more >

github_iconTop Related Medium Post

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