Skip to content

Missing report configuration defaultSummarizer #547

Open

Description

@miyasudokoro
  • 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

Activity

  1. ericmorand commented on Oct 26, 2024

    @ericmorand

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

  2. added a commit that references this issue on Oct 28, 2024
  3. bcoe commented on Dec 10, 2024

    @bcoe
    Owner

    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 👏

  4. miyasudokoro commented on Dec 13, 2024

    @miyasudokoro
    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?
  5. bcoe commented on Dec 20, 2024

    @bcoe
    Owner

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

    #554

  6. bcoe commented on Dec 21, 2024

    @bcoe
    Owner

    @miyasudokoro re:

    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.

    If you start with a fresh checkout (make sure there's no local coverage, tmp, folder etc., ) and run npm ci, npm t should pass.

    How do I add a test for defaultSummarizer?

    To add new tests, you write the test first and then run npm run test:snap to capture the new snapshot. You then just use a visual diff to make sure it looks reasonable.

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

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions