node
node copied to clipboard
Support statement coverage
I think the Node.js coverage reporter should include support for reporting statement coverage.
My idea is to parse the source code into an Abstract Syntax Tree (AST) using acorn-walk
, and then use the Statement
callback to extract statements. They could then be converted to CoverageStatement
s, (similarly to how the getLines
function works with lines to CoverageLines
).
These statements could then be mapped to ranges in the same way that lines are handled in mapRangeToLines
.
I saw a (extremely complicated) way of doing this in https://github.com/cenfun/monocart-coverage-reports/, so it appears to be possible.