Right now we generate coverage and merge it back into the results object at the end after a test run. This has two disadvantages:
by merging coverage info after each test we can avoid both of these issues.
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.
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.