Allow users to create custom summarizers #612
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
SUMMARY
Export a new interface that allows users to create their own custom summarize functions, and to use them when building custom reporters for istanbul (or when calling existing reporters). Today this isn't really possible because the user of
istanbul-lib-reports
can't get access to the underlying structures (like ReportTree) you need to build a summarizer.An example of how an end-user could use this new interface:
DETAILS
I've put together my suggested implementation for this feature, a quick change list:
summarizer
option.summarizer-factory
intosummarizer-core
, pulling the utility functions into aUtil
object.summarizer.js
, which re-exports pieces ofsummarizer-core
._summary
field on ReportBase -- I think it's appropriate to allow custom subclasses of ReportBase to override the_summary
field in their constructor, after calling the super constructor (or even for an end-user to construct a ReportBase object, and then override the field manually before callingexecute()
.)TESTING
I've tested this change using my desired new summarizer (see example above for something close to what I'm looking for), and the existing summarizers (
pkg
,nested
,flat
). Added unit tests to get code coverage back to 100%, but am happy to add more if there's additional functionality I should test.