Jest: [Coverage] Merge coverage info after each test

Created on 12 May 2016  路  6Comments  路  Source: facebook/jest

Right now we generate coverage and merge it back into the results object at the end after a test run. This has two disadvantages:

  • Coverage data is massive and requires a lot of memory
  • We take a significant amount of time to do this at the end of a test run

by merging coverage info after each test we can avoid both of these issues.

Most helpful comment

@cpojer Can I ask why this was closed? My team recently had to turn off coverage requirements in our CI because of process-out-of-memory exceptions. We have a lot of Jest tests :)

Tangentially, has any thought been given to using NYC over istanbul directly? From what I understand NYC wraps istanbul to make it easier to collect coverage from spawned processes. From a cursory glance it looks like they write coverage data from each process to disk instead of trying to hold it in memory or merging on the fly.

All 6 comments

cc @clentfort who expressed interest to help out a bit.

I guess a good starting point for this might be packages/jest-cli/src/reporters/IstanbulTestReporter.js.

But there is a lot of code around for coverage and I'm not even sure if all related code is still alive. I.e in packages/jest-cli/src/Runtime/Runtime.js#getAllCoverageInfo should always return Object {} since this._coverageCollectors is initialized as Object {} and seemingly never reassigned.

It seems like we are already adding coverage information here: https://github.com/facebook/jest/blob/master/packages/jest-cli/src/reporters/IstanbulTestReporter.js#L25

but we also have formatTestResults for JSON printing, which is why we need to retain them. I'd like to take coverage off individual test results and get rid of them after processing them in the IstanbulTestReporter and potentially format them early?

@cpojer Can I ask why this was closed? My team recently had to turn off coverage requirements in our CI because of process-out-of-memory exceptions. We have a lot of Jest tests :)

Tangentially, has any thought been given to using NYC over istanbul directly? From what I understand NYC wraps istanbul to make it easier to collect coverage from spawned processes. From a cursory glance it looks like they write coverage data from each process to disk instead of trying to hold it in memory or merging on the fly.

Sorry, it looked like we weren't going to focus on this anytime soon but @dmitriiabramov made a strong case to me to improve coverage support :)

I think what @dmitriiabramov is doing should be enough to make this reasonable.

Was this page helpful?
0 / 5 - 0 ratings