bcoe / c8

output coverage reports using Node.js' built in coverage
ISC License
2k stars 91 forks source link

Missing report configuration defaultSummarizer #547

Open miyasudokoro opened 1 month ago

miyasudokoro commented 1 month ago

There is a poorly-documented feature of the HTML Istanbul reporters (html, lcov, html-spa) called "defaultSummarizer". It would be nice if c8 could pass through this configuration option so it can be used.

I am willing to create a pull request for this issue myself.

Below is my documentation of what "defaultSummarizer" does from my pull request to @web/test-runner.


For some reporters, you can change the summary and hierarchy of reported files using the option defaultSummarizer.

Example HTML report structures:

Actual file structure:

pkg:

nested:

flat:

ericmorand commented 1 month ago

If you feel like changing for another v8-driven code coverage tool, you can give One Double Zero a try. I just tested and it passes through any reporter options that it receives:

{
  "sources": [
    "./src/main/{.,!(target)/**}/*.ts"
  ],
  "reporters": [
    "html",
    "text"
  ],
  "reporterOptions": {
    "html": {
      "defaultSummarizer": "nested"
    }
  }
}

It is worth noting that the reporterOptions is not documented, which will be fixed: https://gitlab.com/nightlycommit/one-double-zero-documentation/-/issues/2

Note that I didn't know about that option and I have to thank you for that: the nested layout is the one I've been dreaming of ever since I've started using istanbul. 🙏