istanbuljs / puppeteer-to-istanbul

given coverage information output by puppeteer's API output a format consumable by Istanbul reports
ISC License
212 stars 46 forks source link

Provide option to override 'out.json' file name in writeIstanbulFormat #63

Open babaosoftware opened 3 years ago

babaosoftware commented 3 years ago

The file is being overwritten every time a new test suite runs (more precisely, every time "write" is being called), making it impossible to merge the code coverage for multiple test suites. If separate files are generated for each test suite, then a merged report can be created with "nyc report". For example, at the end of a test suite I can put something like this:

afterAll(async () => {
    const [jsCoverage, cssCoverage] = await Promise.all([
        page.coverage.stopJSCoverage(),
        page.coverage.stopCSSCoverage(),
    ]);
    await pti.write([...jsCoverage, ...cssCoverage], {outputName: 'my-test-output'});
    }
});

and then use that option in https://github.com/istanbuljs/puppeteer-to-istanbul/blob/master/lib/puppeteer-to-istanbul.js line 27: const outFilePath =${this.storagePath}/${this.options.outputName || 'out'}.json This way the test suites will generate separate files, that can be at the end merged with "nyc report".

umarkhanTR commented 1 year ago

This issue is still open. Any ETA on fixing this overwriting logs behavior? Or any work around?

Aaron3963 commented 3 months ago

Upvoting on this. I have to run one test, rename it before I can run the next one. Should be an easy fix as babao suggested.