puppeteer-to-istanbul icon indicating copy to clipboard operation
puppeteer-to-istanbul copied to clipboard

Collecting Coverage for Multiple Pages

Open Neuroforge opened this issue 5 years ago • 5 comments

Hello,

I am running a number of tests that need me to refresh the page.

When i run one test i get a single nyc_output file as expected. When i create a new test, with a new page object, the code coverage collection needs to be restarted.

Can i aggregate code coverage results for many pages? Can code coverage persist between page refreshes?

Kind regards,

Daniel

Neuroforge avatar Feb 13 '20 06:02 Neuroforge

@Neuroforge Puppeteer has an option to reset coverage on navigation which is on by default. https://github.com/puppeteer/puppeteer/blob/v2.1.1/docs/api.md#coveragestartjscoverageoptions Disabling this option will probably solve your problem.

SanterreJo avatar Feb 13 '20 13:02 SanterreJo

Setting resetOnNavigation does work but because puppeteer-to-istanbul creates unique filenames for the source files, the generated reports show many instances of the same files instead of a combined coverage which is the most common use case.

My workaround is that I vendored in puppeteer-to-istanbul and made modifications so that it creates multiple out.json files and I removed the unique filename feature. That did the trick for me.

arienkock avatar Apr 12 '20 11:04 arienkock

Hi there! The issue is still actual, we trigger reload on each test and result not very nice

Screenshot from 2020-05-31 09-45-37

Would be grate to have some solution OOB

dimanech avatar May 31 '20 06:05 dimanech

Setting resetOnNavigation does work but because puppeteer-to-istanbul creates unique filenames for the source files, the generated reports show many instances of the same files instead of a combined coverage which is the most common use case.

My workaround is that I vendored in puppeteer-to-istanbul and made modifications so that it creates multiple out.json files and I removed the unique filename feature. That did the trick for me.

Can I see your revised code

lidongxue avatar Jun 05 '20 09:06 lidongxue

Sure. Here's an attempt. It's been a while.

https://github.com/istanbuljs/puppeteer-to-istanbul/compare/v1.2.2...arienkock:master

arienkock avatar Jun 06 '20 13:06 arienkock