@greguintow/jest-coverage-badges

中文文档
1.1.3发布于 2023/03/01MITCommonJS近 30 天下载 2万

Create a group of coverage badges from jest

原始使用文档
文档目录3 节
  1. Usage
  2. Why use this package?
  3. Author of adaptation of (make-coverage-badge)

Jest Coverage Badges

Create a group of coverage badge

License npm

Creates a group of code coverage badges like the following:

Coverage badge gree Coverage badge gree Coverage badge gree

Currently just reads from Istanbul's JSON summary reporter and downloads a badge from https://shields.io/ for each jest coverage type (statement, branch, functions, lines). Like this:

Coverage lines Coverage functions Coverage branches Coverage statements

This package is an extension of make-coverage-badge, but this one creates all the types of coverage.

Usage

  1. Install jest-coverage-badges in your project or global

    Project (in your project folder):

    npm install --save jest-coverage-badges

    Global:

    npm install --global jest-coverage-badges

  2. Configure Jest (in package.json):

    (optional: "text" and "lcov")

    "jest": {
      "coverageReporters": [
        "json-summary", 
        "text",
        "lcov"
      ]
    }
    

    If you installed in your project, you can create a script to run it, for example:

    "scripts": {
      "test:coverage": "npm test -- --coverage",
      "test:badges": "npm run test:coverage  && jest-coverage-badges"
    }
    
  3. Run npm test -- --coverage

  4. Run jest-coverage-badges (or just run: npm run test:badges)

    Resulting in badges:

    • ./coverage/badge-statements.svg
    • ./coverage/badge-lines.svg
    • ./coverage/badge-functions.svg
    • ./coverage/badge-branches.svg

CLI Options

  • input [default: ./coverage/coverage-summary.json] - the file (and its path) of the summary json that contains the coverage data
  • output [default: ./coverage] - the path to the directory where the svg files will be placed after download. If path doesn't exist it will be created.

Example:
$ jest-coverage-badges --input "./cov" --output "./badges"

After this you can add into Github readme (for example) :smiley:

Why use this package?

We have great companies like coveralls and codecov, but it's paid for private repositories. If this package we can add badges in our readme by creating the badges (this can be run at your build, upload to a store and consume in the readme or the website).

Author of adaptation of (make-coverage-badge)

© 2018 [Main Author of Adaptations] Pamela Peixinho [email protected] (https://pamepeixinho.github.io)

版本与发布记录

@greguintow/jest-coverage-badges 共发布 1 个版本,首次发布于 2023/03/01;过去 12 个月发布了 0 个版本。

版本发布日期距今
1.1.3latest2023/03/013 年前

关于 @greguintow/jest-coverage-badges 的常见问题

@greguintow/jest-coverage-badges 是什么?

Create a group of coverage badges from jest

如何安装 @greguintow/jest-coverage-badges?

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

@greguintow/jest-coverage-badges 支持 TypeScript 吗?

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

@greguintow/jest-coverage-badges 支持 ESM 还是 CommonJS?

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

@greguintow/jest-coverage-badges 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=6.11。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@greguintow/jest-coverage-badges 可以商用吗?

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

@greguintow/jest-coverage-badges 的下载量有多少?

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

@greguintow/jest-coverage-badges 还在维护吗?

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