set DEBUG=cypress*memory && set CYPRESS_INTERNAL_MEMORY_SAVE_STATS=1 && set CYPRESS_NO_COMMAND_LOG=1 && tsc && cypress run --config-file cypress.dev.config.js --browser chrome --headless
// testFile.cy.ts
describe('Test File', () => {
context("Test Suite", { viewportWidth: 1920, viewportHeight: 1080 }, function() {
function setUpAndNavigate() {
cy.visit("http://localhost:5173");
// May not be necessary
return cy.wait(500);
}
// Depending on your available memory, it may take more or less tests to crash the browser. Adjust the number of loops in the code if necessary.
for (let i = 0; i < 1000; ++i) {
it(`Success Test number ${i}`, function() {
setUpAndNavigate();
cy.get("#root h1").should("be.visible");
});
it(`Fail Test number ${i}`, function() {
setUpAndNavigate();
cy.get("#root h1", { timeout: 1}).should("not.exist", { timeout: 1});
});
}
});
});
Cypress Mode
cypress run
Cypress Version
13.6.0
Browser Version
Chrome 131.0.6778.71
Node version
20.9.0
Operating System
Windows 11
Memory Debug Logs
See 2nd comment (logs too big to be uploaded in this section)
Other
More details on the issue
Every time a test fails, the memory usage increases. If you comment the fail tests, and run only the success tests (you can double the amount of loops so the number of tests stays the same), the memory usage won't increase.
This impacts CI run that contains bigger spec files. If any of the big spec file freeze due to that memory issue, none of the other remaining spec files will be run.
This issue also happens on Electron, but Electron will crash and move on to the next spec file. Chrome will hang forever. This is the message displayed by Electron:
We have failed the current spec but will continue running the next spec.
This can happen for a number of different reasons.
If you're running lots of tests on a memory intense application.
Try increasing the CPU/memory on the machine you're running on.
Try enabling experimentalMemoryManagement in your config file.
Try lowering numTestsKeptInMemory in your config file during 'cypress open'.
- This issue happens on 3 different type of applications (Craco React, Vite React, Angular), so the type of app does not matter.
- Replacing the "for" loop with copies of the test also cause the issue
- This issue happens whether testIsolation is set to true or false.
- This issue happens whether experimentalMemoryManagement is set to true or false.
- This issue happens whether CYPRESS_NO_COMMAND_LOG is set to 1 or 0
# Setting up a small app to test this issue
- To create a small app to quickly test this issue, run this command:
npm create vite@latest
Project name:
Select a framework: React
Select a variant: TypeScript
- Run "npm run dev" to launch the Vite-React application. Set the url into your cypress.config.ts file.
Test code to reproduce
Command to run the tests
Configuration file
// Test file
Cypress Mode
cypress run
Cypress Version
13.6.0
Browser Version
Chrome 131.0.6778.71
Node version
20.9.0
Operating System
Windows 11
Memory Debug Logs
See 2nd comment (logs too big to be uploaded in this section)
Other
More details on the issue
Every time a test fails, the memory usage increases. If you comment the fail tests, and run only the success tests (you can double the amount of loops so the number of tests stays the same), the memory usage won't increase.
This impacts CI run that contains bigger spec files. If any of the big spec file freeze due to that memory issue, none of the other remaining spec files will be run.
This can happen for a number of different reasons.
If you're running lots of tests on a memory intense application.
You can learn more here:
https://on.cypress.io/renderer-process-crashed
npm create vite@latest Project name:
Select a framework: React
Select a variant: TypeScript