Library for parsing coverage reports.
npm install @connectis/coverage-parser[![NPM version][npm-image]][npm-url][![Dependency Status][depstat-image]][depstat-url]
This library bundles different coverage parsers that parse coverage information in a uniform way.
Supported coverage report formats:
- lcov
- cobertura
- clover
- jacoco
- golang-cover
Note: if you want to merge the parsed results you can use @connectis/coverage-merger.
js
const coverageParser = require('@connectis/coverage-parser');coverageParser
.parseGlobs('**/lcov.info', {
type: 'lcov'
})
.then(results => console.log(results));
`
API
The API includes the following:
- parseGlobs(globs, options)
- parseFiles(files, options)
- parseFile(file, options)
- types$3
Type ArrayArray of available parser types.
$3
Type object##### options.type
Type:
stringThe type of parser which should be used for parsing the coverage files. See the exported
types array for available types.##### options.parser
Type:
functionCustom parser function for parsing the coverage files:
(file) => Promise. See below.##### options.pathMode
Type:
'absolute' | 'relative' | 'unmodified'Default:
'absolute'The type of paths that should be used in the parsed result. See
options.baseDir.##### options.baseDir
Type:
stringDefault:
process.cwd()The base directory that will be used for making paths relative or absolute in the coverage reports. See
options.pathMode.$3
Finds all coverage reports matching the glob patterns and parses the results.#### globs
Type:
ArrayEither an of glob patterns or a single glob pattern.
#### options
Type:
options. See above.##### options.globOptions
Type:
objectOptions to pass to fast-glob.
#### returns
Type:
Promise. See below.$3
Parses all coverage reports files.#### files
Type:
ArrayAn array of file paths.
#### options
Type:
options. See above.#### returns
Type:
Promise. See below.$3
Parses the coverage reports file.#### file
Type:
stringThe file path.
#### options
Type:
options. See above.#### returns
Type:
Promise. See below.$3
The returned data has the following format.` json
{
"title": "Test #1",
"file": "/some/absolute/path/anim-base/anim-base-coverage.js",
"functions": {
"hit": 23,
"found": 29,
"details": [
{
"name": "(anonymous 1)",
"line": 7,
"hit": 6
},
{
"name": "(anonymous 2)",
"line": 620,
"hit": 225
},
{
"name": "_end",
"line": 516,
"hit": 228
}
]
},
"lines": {
"found": 181,
"hit": 143,
"details": [
{
"line": 7,
"hit": 6
},
{
"line": 29,
"hit": 6
},
{
"line": 41,
"hit": 0
}
]
},
"branches": {
"found": 2,
"hit": 1,
"details": [
{
"line": 9,
"branch": 0,
"taken": 0
},
{
"line": 9,
"branch": 1,
"taken": 1
}
]
}
}
``[npm-url]: https://www.npmjs.org/package/@connectis/coverage-parser
[npm-image]: https://badge.fury.io/js/%40connectis%2Fcoverage-parser.svg
[depstat-url]: https://david-dm.org/Connected-Information-systems/coverage-parser
[depstat-image]: https://david-dm.org/Connected-Information-systems/coverage-parser.svg