{"id":19972632,"url":"https://github.com/jpb06/node-coverage-badges","last_synced_at":"2026-01-18T16:03:19.989Z","repository":{"id":222373766,"uuid":"756611163","full_name":"jpb06/node-coverage-badges","owner":"jpb06","description":"Generating test coverage badges from a json summary file","archived":false,"fork":false,"pushed_at":"2026-01-10T21:26:24.000Z","size":736,"stargazers_count":4,"open_issues_count":12,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-01-10T23:57:52.991Z","etag":null,"topics":["coverage-badges","effect-ts"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jpb06.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2024-02-13T00:13:00.000Z","updated_at":"2025-11-28T19:57:42.000Z","dependencies_parsed_at":"2026-01-03T11:07:12.110Z","dependency_job_id":null,"html_url":"https://github.com/jpb06/node-coverage-badges","commit_stats":null,"previous_names":["jpb06/node-coverage-badges"],"tags_count":45,"template":false,"template_full_name":null,"purl":"pkg:github/jpb06/node-coverage-badges","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jpb06%2Fnode-coverage-badges","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jpb06%2Fnode-coverage-badges/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jpb06%2Fnode-coverage-badges/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jpb06%2Fnode-coverage-badges/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jpb06","download_url":"https://codeload.github.com/jpb06/node-coverage-badges/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jpb06%2Fnode-coverage-badges/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28541068,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-18T14:59:57.589Z","status":"ssl_error","status_checked_at":"2026-01-18T14:59:46.540Z","response_time":98,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["coverage-badges","effect-ts"],"created_at":"2024-11-13T03:08:45.227Z","updated_at":"2026-01-18T16:03:19.984Z","avatar_url":"https://github.com/jpb06.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# node-coverage-badges\n\n[![Open in Visual Studio Code](https://img.shields.io/static/v1?logo=visualstudiocode\u0026label=\u0026message=Open%20in%20Visual%20Studio%20Code\u0026labelColor=2c2c32\u0026color=007acc\u0026logoColor=007acc)](https://github.dev/jpb06/node-coverage-badges)\n![Github workflow](https://img.shields.io/github/actions/workflow/status/jpb06/node-coverage-badges/tests-scan.yml?branch=main\u0026logo=github-actions\u0026label=last%20workflow)\n[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=jpb06_node-coverage-badges\u0026metric=alert_status)](https://sonarcloud.io/summary/new_code?id=jpb06_node-coverage-badges)\n[![Maintainability Rating](https://sonarcloud.io/api/project_badges/measure?project=jpb06_node-coverage-badges\u0026metric=sqale_rating)](https://sonarcloud.io/dashboard?id=jpb06_node-coverage-badges)\n[![Security Rating](https://sonarcloud.io/api/project_badges/measure?project=jpb06_node-coverage-badges\u0026metric=security_rating)](https://sonarcloud.io/dashboard?id=jpb06_node-coverage-badges)\n[![Reliability Rating](https://sonarcloud.io/api/project_badges/measure?project=jpb06_node-coverage-badges\u0026metric=reliability_rating)](https://sonarcloud.io/dashboard?id=jpb06_node-coverage-badges)\n[![Coverage](https://sonarcloud.io/api/project_badges/measure?project=jpb06_node-coverage-badges\u0026metric=coverage)](https://sonarcloud.io/dashboard?id=jpb06_node-coverage-badges)\n![Coverage](./badges/coverage-total.svg)\n[![Lines of Code](https://sonarcloud.io/api/project_badges/measure?project=jpb06_node-coverage-badges\u0026metric=ncloc)](https://sonarcloud.io/summary/new_code?id=jpb06_node-coverage-badges)\n[![Technical Debt](https://sonarcloud.io/api/project_badges/measure?project=jpb06_node-coverage-badges\u0026metric=sqale_index)](https://sonarcloud.io/summary/new_code?id=jpb06_node-coverage-badges)\n[![Code Smells](https://sonarcloud.io/api/project_badges/measure?project=jpb06_node-coverage-badges\u0026metric=code_smells)](https://sonarcloud.io/dashboard?id=jpb06_node-coverage-badges)\n[![Bugs](https://sonarcloud.io/api/project_badges/measure?project=jpb06_node-coverage-badges\u0026metric=bugs)](https://sonarcloud.io/summary/new_code?id=jpb06_node-coverage-badges)\n[![Vulnerabilities](https://sonarcloud.io/api/project_badges/measure?project=jpb06_node-coverage-badges\u0026metric=vulnerabilities)](https://sonarcloud.io/summary/new_code?id=jpb06_node-coverage-badges)\n[![Duplicated Lines (%)](https://sonarcloud.io/api/project_badges/measure?project=jpb06_node-coverage-badges\u0026metric=duplicated_lines_density)](https://sonarcloud.io/dashboard?id=jpb06_node-coverage-badges)\n![npm bundle size](https://img.shields.io/bundlephobia/min/node-coverage-badges)\n![Last commit](https://img.shields.io/github/last-commit/jpb06/node-coverage-badges?logo=git)\n\nGenerating coverage badges from jest coverage report.\n\n\u003c!-- readme-package-icons start --\u003e\n\n\u003cp align=\"left\"\u003e\u003ca href=\"https://docs.github.com/en/actions\" target=\"_blank\"\u003e\u003cimg height=\"50\" width=\"50\" src=\"https://raw.githubusercontent.com/jpb06/jpb06/master/icons/GithubActions-Dark.svg\" /\u003e\u003c/a\u003e\u0026nbsp;\u003ca href=\"https://www.typescriptlang.org/docs/\" target=\"_blank\"\u003e\u003cimg height=\"50\" width=\"50\" src=\"https://raw.githubusercontent.com/jpb06/jpb06/master/icons/TypeScript.svg\" /\u003e\u003c/a\u003e\u0026nbsp;\u003ca href=\"https://nodejs.org/en/docs/\" target=\"_blank\"\u003e\u003cimg height=\"50\" width=\"50\" src=\"https://raw.githubusercontent.com/jpb06/jpb06/master/icons/NodeJS-Dark.svg\" /\u003e\u003c/a\u003e\u0026nbsp;\u003ca href=\"https://bun.sh/docs\" target=\"_blank\"\u003e\u003cimg height=\"50\" width=\"50\" src=\"https://raw.githubusercontent.com/jpb06/jpb06/master/icons/Bun-Dark.svg\" /\u003e\u003c/a\u003e\u0026nbsp;\u003ca href=\"https://biomejs.dev/guides/getting-started/\" target=\"_blank\"\u003e\u003cimg height=\"50\" width=\"50\" src=\"https://raw.githubusercontent.com/jpb06/jpb06/master/icons/Biome-Dark.svg\" /\u003e\u003c/a\u003e\u0026nbsp;\u003ca href=\"https://vitest.dev/guide/\" target=\"_blank\"\u003e\u003cimg height=\"50\" width=\"50\" src=\"https://raw.githubusercontent.com/jpb06/jpb06/master/icons/Vitest-Dark.svg\" /\u003e\u003c/a\u003e\u0026nbsp;\u003ca href=\"https://www.effect.website/docs/quickstart\" target=\"_blank\"\u003e\u003cimg height=\"50\" width=\"50\" src=\"https://raw.githubusercontent.com/jpb06/jpb06/master/icons/Effect-Dark.svg\" /\u003e\u003c/a\u003e\u003c/p\u003e\n\n\u003c!-- readme-package-icons end --\u003e\n\n## ⚡ Badges for everyone\n\nThis package uses [shields.io](https://shields.io/) to created coverage badges from a coverage json summary file generated by your favorite test runner.\n\n| Badge                                           | Description                                    |\n| ----------------------------------------------- | ---------------------------------------------- |\n| ![Branches](./badges/coverage-branches.svg)     | Percentage of DD-paths followed during tests   |\n| ![Functions](./badges/coverage-functions.svg)   | Percentage of functions executed within tests  |\n| ![Lines](./badges/coverage-lines.svg)           | Percentage of lines covered by tests           |\n| ![Statements](./badges/coverage-statements.svg) | Percentage of statements executed within tests |\n| ![Tests coverage](./badges/coverage-total.svg)  | Average of the above coverage percentages      |\n\n## ⚡ Github action\n\nIf you want to integrate this to your CI/CD, you have a [github action available for this](https://github.com/marketplace/actions/coverage-badges-generation-action).\n\n## ⚡ Requirements\n\nYou need a test runner to generate the report summary file. For example [vitest](https://vitest.dev/guide/) or [jest](https://jestjs.io/docs/getting-started).\n\n## ⚡ Setup\n\n### 🔶 Install\n\n```shell\nnpm i -D node-coverage-badges\n# or\nyarn add -D node-coverage-badges\n# or\npnpm i -D node-coverage-badges\n```\n\n### 🔶 Test runner configuration\n\nYou will need to add json-summary to coverage reporters in your test runner config.\n\n#### 🧿 vitest\n\n`vite config`\n\n```typescript\nimport { defineConfig } from 'vitest/config';\n\nexport default defineConfig({\n  test: {\n    coverage: {\n      reporter: ['json-summary'],\n      // ...\n    },\n  },\n});\n```\n\n#### 🧿 jest\n\n`jest config`\n\n```javascript\nmodule.exports = {\n   coverageReporters: [\"json-summary\"];\n   // ...\n};\n```\n\n## ⚡ Usage\n\nYou have two ways to generate coverage badges: cli and node. Both will create a folder where .svg files will be written.\n\n### 🔶 Cli\n\n```bash\ngenerateBadges -c [coverageJsonSummaryPath] -o [outputPath] -l [logo]\n\nOptions:\n      --help     Show help                                             [boolean]\n      --version  Show version number                                   [boolean]\n  -c             coverage file path[default: \"./coverage/coverage-summary.json\"]\n  -o             output path                               [default: \"./badges\"]\n  -l             vitest                                [default: \u003cdefault icon\u003e]\n  -p             badges label prefix                  [default: \"Test coverage\"]\n  -d             debug                                          [default: false]\n\nExamples:\n  generateBadges -c ./coverage/coverage-summary.json -o ./badges -l vitest\n\nGenerates badges from a coverage report\n\n```\n\nYou can add a script to your package.json like so:\n\n```json\n  \"scripts\": {\n    \"badges\": \"generateBadges\", // cjs\n    \"badges-esm\": \"generateBadgesEsm\" // esm\n  },\n```\n\nThe `generateBadges` function accepts three optional arguments to specify:\n\n- a custom path for the input json summary file.\n- a custom path for the output path.\n- a [simple icon](https://simpleicons.org/) slug to specify a custom badge icon.\n\n```shell\n# will generate badges from './coverage/coverage-summary.json' in './badges' (default)\npnpm generateBadges\n\n# will generate badges from './myModule/coverage-summary.json' in './cool' folder.\npnpm generateBadges -c ./myModule/coverage-summary.json -o ./cool\n\n# will generate badges from './myModule/coverage-summary.json' in './cool' folder using the vitest icon.\npnpm generateBadges -c ./myModule/coverage-summary.json -o ./cool -l vitest\n\n# will generate badges from './myModule/coverage-summary.json' in './cool' folder using the vitest icon with badges labels matching 'Repo test coverage: %d'.\npnpm generateBadges -c ./myModule/coverage-summary.json -o ./cool -l vitest -p 'Repo test coverage'\n```\n\n### 🔶 Node\n\nYou can generate badges from a summary file or raw values in node.\n\n#### 🧿 Generate badges from a summary file\n\n```typescript\nimport { generateBadges } from 'node-coverage-badges';\n\n// will generate badges from './coverage/coverage-summary.json' in './badges' (default)\nawait generateBadges();\n```\n\nThe function optionally accepts two arguments to specify a custom path for the json summary file and the output path:\n\n```typescript\nimport { generateBadges } from 'node-coverage-badges';\n\n// will generate badges from './myModule/coverage-summary.json' in './cool' using the jest icon.\nawait generateBadges(\n  './myModule/coverage-summary.json',\n  './cool',\n  'jest',\n  'My badges labels prefix'\n);\n```\n\nYou can also directly import the effect, if you use [Effect](https://effect.website/docs/introduction):\n\n```typescript\nimport { generateBadgesEffect } from 'node-coverage-badges';\n\nconst task = Effect.gen(function* () {\n  //...\n\n  const result = yield* generateBadgesEffect();\n});\n```\n\nThe function signature is the following:\n\n```typescript\nconst generateBadgesEffect: (\n  coverageSummaryPath?: string,\n  outputPath?: string,\n  logo?: string\n  labelPrefix?: string\n) =\u003e Effect.Effect\u003cboolean, FsError | AxiosError, never\u003e;\n```\n\n#### 🧿 Generate badges from raw values\n\n```typescript\nimport { generateBadgesFromValues } from 'node-coverage-badges';\n\nconst rawValues = {\n  total: {\n    branches: {\n      pct: 25,\n    },\n    functions: {\n      pct: 40,\n    },\n    lines: {\n      pct: 30,\n    },\n    statements: {\n      pct: 70,\n    },\n  },\n};\n\nawait generateBadgesFromValues(rawValues, './badges', 'vitest', 'Coverage');\n```\n\nEffect signature is the following:\n\n```typescript\nconst generateBadgesFromValuesEffect: (\n  summaryValues: CoverageSummaryValue,\n  outputPath?: string,\n  logo?: string\n  labelPrefix?: string\n) =\u003e Effect.Effect\u003cboolean, FsError | AxiosError, never\u003e;\n```\n\n#### 🧿 Debug\n\nYou can pass a boolean as last argument to get generation info:\n\n```typescript\nimport { generateBadges } from 'node-coverage-badges';\n\nawait generateBadges(\n  './myModule/coverage-summary.json',\n  './cool',\n  'jest',\n  'My badges labels prefix'\n  true\n);\n```\n\nWhich will provide the following kind of output:\n\n![Debug](./assets/debug.png)\n\n## ⚡ Thanks\n\nBig thanks to [Shield](https://github.com/badges/shields) for this awesome tool!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjpb06%2Fnode-coverage-badges","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjpb06%2Fnode-coverage-badges","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjpb06%2Fnode-coverage-badges/lists"}