Skip to content

task "combineCoverage" times out for big projects #76

Closed
@jidma

Description

@jidma

I have a project with 424 instrumented source files.

The task "combineCoverage" allways runs into a timeout (even after waiting for 2h30).

cypress1

After some digging:

I added some debug in the following code:

code-coverage/support.js

Lines 17 to 29 in 40a602d

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) {
cy.task('combineCoverage', applicationSourceCoverage)
}
})
})

  • 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:

cypress2

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions