Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Removing / ignoring Istanbul html or lcov coverage report footer timestamp

Right now I have a monorepo using lerna, each package has it's own tests / coverage tools, meaning one package can use ava + nyc another can use jest. I am building the coverage for each package individually so each package has it's own coverage folder. This is causing lerna to be unable to tell which packages to update when I publish because, whenever I run a new test, I have a commit littered with new coverage files all because of this one line:

Code coverage generated by istanbul at Wed Apr 25 2018 00:03:42 GMT-0400 (EDT)

I've tracked down the footer in istanbul and could possibly add a new reporter that would not have the timestamp in the footer, the chances of istanbul taking this change in is slim.

I am looking for a way using git / diffing to ignore (checkout) a change to this line in a file. The issue is there's no consistent way (possibly regex) to ignore this file, meaning it's not always going to be on the same line. So I can't use a patch file.

I would love any suggestions for ignoring a given change to a specific file like this.

Options:

  1. Look into adding PR to istanbul or forking with timestamp removed (unfavorable)
  2. When a new coverage is generated and the diff between the latest and the new one is only this footer change, the files are revered via checkout preserving the original timestamp if no actual changes were made.
  3. Create a script using jsdom parse the html files with node and remove the timestamp all together and update the coverage files after the coverage script has run.

Looking for suggestions!

like image 392
ThomasReggi Avatar asked Dec 09 '25 17:12

ThomasReggi


1 Answers

I solved this problem in a bit of a different way.

A. I altered the coverage reporters to only provide JSON which don't contain any specific timestamp data.

lerna exec -- "json -I -e \"this.jest.coverageReporters=['json']\" -f ./package.json"

B. I deleted all the reports only leaving the JSON

lerna exec -- rm -rf ./coverage/lcov-report

C. Added script to parent project to build coverage (merging all json files)

istanbul report --include=./packages/**/coverage/coverage-final.json

This has the added benefit of generating one site for all packages regardless of how the packages are being tested.

like image 126
ThomasReggi Avatar answered Dec 11 '25 05:12

ThomasReggi



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!