Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing report configuration defaultSummarizer #547

Open
miyasudokoro opened this issue Oct 25, 2024 · 4 comments
Open

Missing report configuration defaultSummarizer #547

miyasudokoro opened this issue Oct 25, 2024 · 4 comments

Comments

@miyasudokoro
Copy link

  • Version: all
  • Platform: all

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.

  • pkg
    • The default setting
    • Lists every subdirectory path on the main index page
    • Shows the summary of the files in each subdirectory
    • You must click into each subdirectory to see files
  • nested:
    • Displays nested file structure, like in your operating system or IDE
    • Shows a deep summary of all the contents of each directory
    • You must click through the directory structure to each file
  • flat:
    • All files are in one flat list
    • No directory-based summaries
    • There is only one page of results

Example HTML report structures:

Actual file structure:

  • js
    • a.js
    • controller
      • b.js
      • manager
        • factory
          • c.js

pkg:

  • js
    • a.js
  • js/controller
    • b.js
  • js/controller/manager/factory
    • c.js

nested:

  • a.js
  • controller
    • b.js
    • manager
      • factory
        • c.js

flat:

  • a.js
  • controller/b.js
  • controller/manager/factory/c.js
@ericmorand
Copy link

ericmorand commented Oct 26, 2024

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. 🙏

miyasudokoro pushed a commit to miyasudokoro/c8 that referenced this issue Oct 28, 2024
@bcoe
Copy link
Owner

bcoe commented Dec 10, 2024

If you feel like changing for another v8-driven code coverage tool

@ericmorand I haven't been putting work into open source, so I deserve this... But, using my repos to advertise your own open source projects is still a little gauche 😛

There is a poorly-documented feature of the HTML Istanbul

@miyasudokoro send me a patch and I will happily expose this 👏

@miyasudokoro
Copy link
Author

@bcoe I've never done any testing with "snapshots" before, so I don't know how to finish. (See my commit above.)

  1. The test "should allow for multiple overrides of src location for --all" does not pass and I don't know why or how to fix it.
  2. How do I add a test for defaultSummarizer?

@bcoe
Copy link
Owner

bcoe commented Dec 20, 2024

@miyasudokoro I created a draft PR here you could use for a starting point, if your'e so inclined:

#554

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants