{"id":15645469,"url":"https://github.com/jaydenseric/coverage-node","last_synced_at":"2025-04-14T10:33:20.836Z","repository":{"id":36549497,"uuid":"228323167","full_name":"jaydenseric/coverage-node","owner":"jaydenseric","description":"A simple CLI to run Node.js and report code coverage.","archived":false,"fork":false,"pushed_at":"2022-08-18T06:42:39.000Z","size":140,"stargazers_count":56,"open_issues_count":0,"forks_count":3,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-10T02:00:06.611Z","etag":null,"topics":["esm","maintained","mjs","node","npm","npx","v8"],"latest_commit_sha":null,"homepage":"https://npm.im/coverage-node","language":"JavaScript","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/jaydenseric.png","metadata":{"files":{"readme":"readme.md","changelog":"changelog.md","contributing":null,"funding":".github/funding.yml","license":"license.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":"jaydenseric"}},"created_at":"2019-12-16T06:59:31.000Z","updated_at":"2025-01-03T13:48:30.000Z","dependencies_parsed_at":"2022-08-08T15:30:38.955Z","dependency_job_id":null,"html_url":"https://github.com/jaydenseric/coverage-node","commit_stats":null,"previous_names":[],"tags_count":16,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jaydenseric%2Fcoverage-node","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jaydenseric%2Fcoverage-node/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jaydenseric%2Fcoverage-node/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jaydenseric%2Fcoverage-node/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jaydenseric","download_url":"https://codeload.github.com/jaydenseric/coverage-node/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248862868,"owners_count":21173897,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["esm","maintained","mjs","node","npm","npx","v8"],"created_at":"2024-10-03T12:07:53.798Z","updated_at":"2025-04-14T10:33:20.808Z","avatar_url":"https://github.com/jaydenseric.png","language":"JavaScript","readme":"# coverage-node\n\nA simple CLI to run [Node.js](https://nodejs.org) and report code coverage.\n\n- ✨ Zero config.\n- 🏁 Tiny source, written from scratch to use [code coverage features](https://nodejs.org/api/cli.html#cli_node_v8_coverage_dir) built into Node.js.\n- 📦 [Lean install size](https://packagephobia.com/result?p=coverage-node), compared to [1.94 MB for `c8` v7.11.1](https://packagephobia.com/result?p=c8@7.11.1) or [8.84 MB for `nyc` v15.1.0](https://packagephobia.com/result?p=nyc@15.1.0).\n- 🖱 Displays ignored or uncovered source code ranges as paths, clickable in IDEs such as [VS Code](https://code.visualstudio.com).\n\n## Installation\n\nTo install [`coverage-node`](https://npm.im/coverage-node) with [npm](https://npmjs.com/get-npm), run:\n\n```sh\nnpm install coverage-node --save-dev\n```\n\nIn a [`package.json` script](https://docs.npmjs.com/cli/v8/configuring-npm/package-json#scripts), replace the `node` command with [`coverage-node`](#command-coverage-node):\n\n```diff\n {\n   \"scripts\": {\n-    \"test\": \"node test.mjs\"\n+    \"test\": \"coverage-node test.mjs\"\n   }\n }\n```\n\n## Requirements\n\nSupported operating systems:\n\n- Linux\n- macOS\n\nSupported runtime environments:\n\n- [Node.js](https://nodejs.org) versions `^14.17.0 || ^16.0.0 || \u003e= 18.0.0`.\n\nProjects must configure [TypeScript](https://typescriptlang.org) to use types from the ECMAScript modules that have a `// @ts-check` comment:\n\n- [`compilerOptions.allowJs`](https://typescriptlang.org/tsconfig#allowJs) should be `true`.\n- [`compilerOptions.maxNodeModuleJsDepth`](https://typescriptlang.org/tsconfig#maxNodeModuleJsDepth) should be reasonably large, e.g. `10`.\n- [`compilerOptions.module`](https://typescriptlang.org/tsconfig#module) should be `\"node16\"` or `\"nodenext\"`.\n\n## Ignored files\n\nCode coverage analysis ignores:\n\n- `node_modules` directory files, e.g. `node_modules/foo/index.mjs`.\n- `test` directory files, e.g. `test/index.mjs`.\n- Files with `.test` prefixed before the extension, e.g. `foo.test.mjs`.\n- Files named `test` (regardless of extension), e.g. `test.mjs`.\n\n## Ignored lines\n\nIn source code, a comment (case insensitive) can be used to ignore code coverage ranges that start on the the next line:\n\n```js\n// coverage ignore next line\nif (false) console.log(\"Never runs.\");\n```\n\n## CLI\n\n### Command `coverage-node`\n\nSubstitutes the normal `node` command; any [`node` CLI options](https://nodejs.org/api/cli.html#cli_options) can be used to run a test script. If the script doesn’t error a code coverage analysis is reported to the console, and if coverage is incomplete and there isn’t a truthy `ALLOW_MISSING_COVERAGE` environment variable the process exits with code `1`.\n\n#### Examples\n\n[`npx`](https://docs.npmjs.com/cli/v8/commands/npx) can be used to quickly check code coverage for a script:\n\n```sh\nnpx coverage-node test.mjs\n```\n\nA [`package.json` script](https://docs.npmjs.com/cli/v8/configuring-npm/package-json#scripts):\n\n```json\n{\n  \"scripts\": {\n    \"test\": \"coverage-node test.mjs\"\n  }\n}\n```\n\nA [`package.json` script](https://docs.npmjs.com/cli/v8/configuring-npm/package-json#scripts) that allows missing coverage:\n\n```json\n{\n  \"scripts\": {\n    \"test\": \"ALLOW_MISSING_COVERAGE=1 coverage-node test.mjs\"\n  }\n}\n```\n\n## Exports\n\nThe [npm](https://npmjs.com) package [`coverage-node`](https://npm.im/coverage-node) features [optimal JavaScript module design](https://jaydenseric.com/blog/optimal-javascript-module-design). It doesn’t have a main index module, so use deep imports from the ECMAScript modules that are exported via the [`package.json`](./package.json) field [`exports`](https://nodejs.org/api/packages.html#exports):\n\n- [`analyseCoverage.mjs`](./analyseCoverage.mjs)\n- [`reportCoverage.mjs`](./reportCoverage.mjs)\n","funding_links":["https://github.com/sponsors/jaydenseric"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjaydenseric%2Fcoverage-node","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjaydenseric%2Fcoverage-node","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjaydenseric%2Fcoverage-node/lists"}