-
-
Notifications
You must be signed in to change notification settings - Fork 35.3k
Support statement coverage #54530
Copy link
Copy link
Open
Labels
coverageIssues and PRs related to native coverage support.Issues and PRs related to native coverage support.feature requestIssues that request new features to be added to Node.js.Issues that request new features to be added to Node.js.never-staleMark issue so that it is never considered staleMark issue so that it is never considered staletest_runnerIssues and PRs related to the test runner subsystem.Issues and PRs related to the test runner subsystem.
Metadata
Metadata
Assignees
Labels
coverageIssues and PRs related to native coverage support.Issues and PRs related to native coverage support.feature requestIssues that request new features to be added to Node.js.Issues that request new features to be added to Node.js.never-staleMark issue so that it is never considered staleMark issue so that it is never considered staletest_runnerIssues and PRs related to the test runner subsystem.Issues and PRs related to the test runner subsystem.
Type
Projects
Status
Triaged
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 theStatementcallback to extract statements. They could then be converted toCoverageStatements, (similarly to how thegetLinesfunction works with lines toCoverageLines).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.