Description
I have a project with 424 instrumented source files.
The task "combineCoverage" allways runs into a timeout (even after waiting for 2h30).
After some digging:
I added some debug in the following code:
Lines 17 to 29 in 40a602d
-
I found out that my
win.__coverage__
contains a huge object (with 424 entries) that serializes to a 7.5MB string. -
The
combineCoverage
task is never reached (I added a debug at the beginning and it never prints). -
I created an empty task
testTask
which I called using the same object as parameter and it also got stuck. -
when I only instrument 3 files, it works fine.
my workaround
As a workaround, I'm currently 'splitting' my coverage object into smaller chunks (50 entries each). And it works fine.
afterEach(() => {
// save coverage after each test
// because the entire "window" object is about
// to be recycled by Cypress before next test
cy.window().then(win => {
// if application code has been instrumented, the app iframe "window" has an object
const applicationSourceCoverage = win.__coverage__
if (applicationSourceCoverage) {
let i = 0;
let tmpObj = {};
Object.keys(applicationSourceCoverage).forEach(key => {
let value = applicationSourceCoverage[key];
tmpObj[key] = value;
if (++i % 50 == 0) {
cy.log(i + ' - ' + JSON.stringify(tmpObj).length);
cy.task('combineCoverage', tmpObj)
tmpObj = {};
}
});
if (tmpObj !== {}) {
cy.log(i + ' - ' + JSON.stringify(tmpObj).length);
cy.task('combineCoverage', tmpObj)
}
}
})
})
it works fine as a temporary woraround: