# @connectis/diff-test-coverage 中文文档

规范地址：https://npmcn.com/package/%40connectis/diff-test-coverage/

版本：1\.5\.3
npm 元数据更新时间：2022-04-05T00:56:28.246Z
中文译文更新时间：2026-11-10T15:37:29.924Z
软件包许可：MIT

本文由上游 README 翻译，可能存在偏差，请结合原文核对 API、命令与配置。版权与许可归原作者所有。

原始 npm 页面：https://www.npmjs.com/package/%40connectis/diff-test-coverage
原文对照：https://npmcn.com/package/%40connectis/diff-test-coverage/?lang=original
项目主页：https://github.com/Connected-Information-systems/diff-test-coverage#readme
源码仓库：https://github.com/Connected-Information-systems/diff-test-coverage

## 关键信息（来自 npm 元数据）

- 包体积（解压后）：32.1 kB，19 个文件
- TypeScript 类型：未声明
- 运行依赖：10 个
- 首次发布：2018-10-23T12:09:34.177Z
- 最新版本发布：2019-01-31T10:12:38.416Z
- 近 30 天下载量：35407（2026-10-11 至 2026-11-09，npm 官方下载统计）
- 已发布版本数：23（近 12 个月 0 个）

## 中文简介

计算 diffs (源控) 的测试覆盖度的命令行工具 .

## 安装

```sh
npm install @connectis/diff-test-coverage
```

也可以使用：`pnpm add @connectis/diff-test-coverage`、`yarn add @connectis/diff-test-coverage`、`bun add @connectis/diff-test-coverage`

## README

# diff - test - 覆盖

> 一个节点.js命令行工具,根据一个(源控)diff过滤测试覆盖.

[![NPM version](https://badge.fury.io/js/%40connectis%2Fdiff-test-coverage.svg)](https://www.npmjs.org/package/@connectis/diff-test-coverage)[![Dependency Status](https://david-dm.org/Connected-Information-systems/diff-test-coverage.svg)](https://david-dm.org/Connected-Information-systems/diff-test-coverage)

支持的覆盖面报告格式:

-   尔可夫
-   科贝尔图拉
-   花环
-   鸡鸡
-   高朗盖

支持的源控制系统 :

-   图形
-   商品
-   任何能产生统一电源的.

## 安装

1.  安装 [与国家预防机制的节点js](https://nodejs.org/en/download/)
2.  `npm i -g @connectis/diff-test-coverage`

## 示例输出

![Screenshot](https://raw.githubusercontent.com/Connected-Information-systems/diff-test-coverage/master/screenshots/screenshot.png "Example output")

## 用法和选项

执行 `diff-test-coverage` 查看文档.

```
Usage:
1. Execute your tests to generate your test coverage reports.
2. Figure out what Git or Mercurial command to use to generate your diff (see Examples below).
3. Execute: <diff command> | diff-test-coverage -c <coverage report glob> -t <coverage report type> --

Options:
  --help                   Show help  [boolean]
  --version                Show version number  [boolean]
  -c, --coverage           Glob pattern(s) that specify which coverage report files to use.  [array] [required]
  -t, --type               The type of coverage report. When provided multiple times the types will be mapped to the matching coverage glob patterns.  [array] [required] [choices: "lcov", "cobertura", "clover", "jacoco", "golang-cover"]
  -l, --line-coverage      Required line coverage percentage on the diff. The application will exit with -1 if this is not reached.  [number] [default: 80]
  -b, --branch-coverage    Required branch coverage percentage on the diff. The application will exit with -1 if this is not reached.  [number] [default: 80]
  -f, --function-coverage  Required function coverage percentage on the diff. The application will exit with -1 if this is not reached.  [number] [default: 80]
  --diff-base-dir          The base directory for resolving relative paths in the diff. Uses current working directory by default.  [string] [default: `process.cwd()`]
  --diff-filter            Glob pattern(s) that specify which files from the diff should be included.  [array]
  --log-base-dir           The base directory for resolving relative paths in the console logger. Uses current working directory by default.  [string] [default: `process.cwd()`]
  --log-template           The information which should be logged to the console.  [array] [choices: "diff-files", "coverage-files-line", "coverage-files-complete", "totals-line", "totals-complete", "errors"] [default: ["coverage-files-complete","totals-complete","errors"]]
  --color                  Whether colors should be used in the log. Default: autodetect by 'chalk'.  [boolean]

Examples:
  git diff master...MY-BRANCH | diff-test-coverage -c **/coverage.xml -t cobertura --                                                                     Runs 'diff-test-coverage' with a git diff and Cobertura coverage reports.
  hg export -r "branch(.) and not merge()" | diff-test-coverage -c **/target/site/jacoco/jacoco.xml -t jacoco --                                          Runs 'diff-test-coverage' with a mercurial diff and Jacoco coverage reports.
  <diff command> | diff-test-coverage --log-template diff-files coverage-files-line totals-line errors <other args> --                                    Runs 'diff-test-coverage' with custom logging.
  <diff command> | diff-test-coverage --diff-filter *.java *.kt --log-template diff-files coverage-files-complete totals-complete errors <other args> --  Runs 'diff-test-coverage' with the diff filtered on Java and Kotlin files.
  <diff command> | diff-test-coverage --no-color <other args> --                                                                                          Runs 'diff-test-coverage' without color in the log.
  git diff master...MY-BRANCH                                                                                                                             Creates a diff of the Git branch 'MY-BRANCH' which originated from the master branch.
  hg export -r "branch(.) and not merge()"                                                                                                                Creates a diff of the current Mercurial branch, excluding any merge commits.
  hg export -r "branch(MY-BRANCH) and not merge()"                                                                                                        Creates a diff of the Mercurial branch MY-BRANCH, excluding any merge commits.
```

## 常见问题

### @connectis/diff-test-coverage 是什么？

计算 diffs \(源控\) 的测试覆盖度的命令行工具 \.

### 如何安装 @connectis/diff-test-coverage？

在项目目录运行 npm install @connectis/diff-test-coverage，或使用 pnpm add / yarn add / bun add。它还提供命令行工具 diff-test-coverage，可以用 npx diff-test-coverage 直接运行。

### @connectis/diff-test-coverage 支持 TypeScript 吗？

该包的 package\.json 没有声明类型入口。需要类型提示时，可以在 npm 上查找社区维护的 @types/connectis\_\_diff-test-coverage 是否存在。

### @connectis/diff-test-coverage 可以商用吗？

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

### @connectis/diff-test-coverage 的下载量有多少？

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

### @connectis/diff-test-coverage 还在维护吗？

最新版本 1\.5\.3 发布于 2019/01/31（7 年前）；至今共发布 23 个版本，其中过去 12 个月发布了 0 个；首次发布于 2018/10/23。发布频率只是参考信号：功能稳定的工具可能很少需要更新，建议结合源码仓库的 issue 和提交记录判断。

