
Product
Socket for Jira Is Now Available
Socket for Jira lets teams turn alerts into Jira tickets with manual creation, automated ticketing rules, and two-way sync.
The badge above is generated in part by this repo!
CVR has support for processing coverage in Cobertura, LCOV, Jacoco, and Go Cover. Coverage is translated first to a standard JavaScript format and then can be queried for coverage metrics including line, function, and branch coverage. There are also a set of tools for interacting with the GitHub API that make it easier to get files matching coverage reports.
CVR is a node module and does not have browser support.
npm install cvr
var cvr = require( "cvr" );
cvr.getCoverage( coverageFileContents, coverageFileFormat, function ( err, cov )
{
var linePercent = cvr.getLineCoveragePercent( cov );
} );
For more complicated examples, taking a look at /test/test.js is recommended.
Parsers are used for each coverage format to convert the diverse formats into a common format that is used internally for processing. This is the Common Coverage Object and documented on lcov-parse and reproduced below.
{
"title": "Test #1",
"file": "anim-base/anim-base-coverage.js",
"functions": {
"hit": 23,
"found": 29,
"details": [ {
"name": "(anonymous 1)",
"line": 7,
"hit": 6
} ]
},
"lines": {
"found": 181,
"hit": 143,
"details": [ {
"line": 7,
"hit": 6
} ]
},
"branches": {
"found": 123,
"hit": 456,
"details": [ {
"line": 7,
"hit": 6
} ]
}
}
getCoverage( content, type, callback )content | String | the code coverage file contentstype | String [ "lcov" | "cobertura" | "gocover" | "jacoco" ] | the code coverage file typecallback | Function | Callback args Error, Array of Common Coverage ObjectsgetFileCoverage( coverageArray, filePath )coverageArray | Array of Common Coverage Objects | array of file coveragefilePath | String | the file to find in coverageArrayundefinedgetLine( lineCoverage, line )lineCoverage | Line Coverage from Common Coverage Object | array of file coverageline | Number | the line number to findactive whether a line was coveredhit whether it was hit where and hit=null when active=falsegetLineCoveragePercent( coverageArray )coverageArray | Array of Common Coverage Objects | array of file coveragelinesCovered( coverage )coverage | Common Coverage Objects | file coveragelinesMissing( coverage )coverage | Common Coverage Objects | file coveragegetFileType( filePath )filePath | String | the file name or pathfilePath extensionrenderCoverage( coverage, source )coverage | Common Coverage Object | the file coveragesource | String | the file contents<span>s to indicate whether the line was hit or not.formatCoverage( coverage, source, filePath, callback )Returns a complete template with code coloring and syntax highlighting, as compared to renderCoverage which just returns an HTML snippet.
coverage | Common Coverage Object | the file coveragesource | String | the file contentsfilePath | String | the file pathcallback | Function, args err: Error, String: html | html is created based on the source/templates/basic.html filesortCoverage( coverageArray )coverageArray | Array of Common Coverage Objects | array of file coveragegitHub.getFile( accessToken, owner, repoName, commitHash, filePath, callback )accessToken | String | GitHub access tokenowner | String | GitHub file ownerrepoName | String | GitHub repo namecommitHash | String | GitHub commit hash (sha)filePath | String | GitHub file path (this must match the path on GitHub, not the local file path)callback | Function, args err: Error, String: contents | contents is the file contentsgitHub.getRepos( accessToken, callback )This is a convenience method that collects repos from the user's org and own repos
accessToken | String | GitHub access tokencallback | Function, args err: Error, Array: repos | repos is a list of all the repos, the order is not guaranteed to be consistentgitHub.getOwnerRepos( accessToken, callback )accessToken | String | GitHub access tokencallback | Function, args err: Error, Array: repos | repos is a list of all the owner's reposgitHub.getOrgRepos( accessToken, org, callback )accessToken | String | GitHub access tokenorg | String | GitHub organization namecallback | Function, args err: Error, Array: repos | repos is a list of all the org's reposgitHub.createStatus( accessToken, message, callback )accessToken | String | GitHub access tokenmessage follows http://mikedeboer.github.io/node-github/#statuses.prototype.create and is passed along directly.callback | Function, args err: Error | callback is invoked directly by the GitHub modulegitHub.getOrgs( accessToken, callback )accessToken | String | GitHub access tokencallback | Function, args err: Error | callback is invoked directly by the GitHub modulegitHub.getHookByUrl( accessToken, owner, repoName, hookUrl, callback )accessToken | String | GitHub access tokenowner | String | GitHub hook ownerrepoName | String | GitHub repo namehookUrl | String | URL of hookcallback | Function, args err: Error | callback is invoked directly by the GitHub modulegitHub.createHook( accessToken, owner, repoName, hookUrl, callback )accessToken | String | GitHub access tokenowner | String | GitHub hook ownerrepoName | String | GitHub repo namehookUrl | String | URL of hookcallback | Function, args err: Error | callback is invoked directly by the GitHub modulegitHub.deleteHook( accessToken, owner, repoName, hookUrl, callback )accessToken | String | GitHub access tokenowner | String | GitHub hook ownerrepoName | String | GitHub repo namehookUrl | String | URL of hookcallback | Function, args err: Error | callback is invoked directly by the GitHub modulenpm test
Or to run with coverage statistics npm run testcover
A JSCS file is included. Please check any changes against the code standards defined in that file. All changes should have tests.
MIT
FAQs
code coverage tools
The npm package cvr receives a total of 1 weekly downloads. As such, cvr popularity was classified as not popular.
We found that cvr demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Product
Socket for Jira lets teams turn alerts into Jira tickets with manual creation, automated ticketing rules, and two-way sync.

Company News
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.

Security News
NIST will stop enriching most CVEs under a new risk-based model, narrowing the NVD's scope as vulnerability submissions continue to surge.