@connectis/coverage-parser

中文文档
1.0.8发布于 2019/01/31MITCommonJS近 30 天下载 3.6万

Library for parsing coverage reports.

原始使用文档
文档目录8 节
  1. Example
  2. API
  3. types
  4. options
  5. parseGlobs(globs, options)
  6. parseFiles(files, options)
  7. parseFile(file, options)
  8. CoverageResult

coverage-parser

A Node.js library for parsing coverage reports.

NPM versionDependency Status

This library bundles different coverage parsers that parse coverage information in a uniform way. Supported coverage report formats:

Note: if you want to merge the parsed results you can use @connectis/coverage-merger.

Example

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

types

Type Array<string>

Array of available parser types.

options

Type object

options.type

Type: string

The type of parser which should be used for parsing the coverage files. See the exported types array for available types.

options.parser

Type: function

Custom parser function for parsing the coverage files: (file) => Promise<Array<CoverageResult>>. 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: string

Default: process.cwd()

The base directory that will be used for making paths relative or absolute in the coverage reports. See options.pathMode.

parseGlobs(globs, options)

Finds all coverage reports matching the glob patterns and parses the results.

globs

Type: Array<string>|string

Either an of glob patterns or a single glob pattern.

options

Type: options. See above.

options.globOptions

Type: object

Options to pass to fast-glob.

returns

Type: Promise<Array<CoverageResult>>. See below.

parseFiles(files, options)

Parses all coverage reports files.

files

Type: Array<string>

An array of file paths.

options

Type: options. See above.

returns

Type: Promise<Array<CoverageResult>>. See below.

parseFile(file, options)

Parses the coverage reports file.

file

Type: string

The file path.

options

Type: options. See above.

returns

Type: Promise<Array<CoverageResult>>. See below.

CoverageResult

The returned data has the following format.

{
  "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
      }
    ]
  }
}

版本与发布记录

@connectis/coverage-parser 共发布 9 个版本,首次发布于 2018/10/24;过去 12 个月发布了 0 个版本。

版本发布日期距今
1.0.8latest2019/01/317 年前
1.0.72019/01/317 年前
1.0.62018/11/167 年前
1.0.52018/10/308 年前
1.0.42018/10/268 年前
1.0.32018/10/248 年前

关于 @connectis/coverage-parser 的常见问题

@connectis/coverage-parser 是什么?

Library for parsing coverage reports.

如何安装 @connectis/coverage-parser?

在项目目录运行 npm install @connectis/coverage-parser,或使用 pnpm add / yarn add / bun add。

@connectis/coverage-parser 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/connectis__coverage-parser 是否存在。

@connectis/coverage-parser 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@connectis/coverage-parser 可以商用吗?

@connectis/coverage-parser 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@connectis/coverage-parser 的下载量有多少?

根据 npm 官方下载统计,@connectis/coverage-parser 在 2026/10/11 – 2026/11/09 这 30 天内被下载 35,740 次,日均约 1,191 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@connectis/coverage-parser 还在维护吗?

最新版本 1.0.8 发布于 2019/01/31(7 年前);至今共发布 9 个版本,其中过去 12 个月发布了 0 个;首次发布于 2018/10/24。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。