{"id":17472707,"url":"https://github.com/shinnn/coverage","last_synced_at":"2025-04-09T22:54:24.515Z","repository":{"id":57209935,"uuid":"179899855","full_name":"shinnn/coverage","owner":"shinnn","description":"Collect and report code coverage of a JavaScript program","archived":false,"fork":false,"pushed_at":"2019-06-26T12:45:18.000Z","size":157,"stargazers_count":13,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-09T22:54:19.235Z","etag":null,"topics":["code-coverage","command-line-tool","coverage-report","ecmascript","javascript","nodejs"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/shinnn.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-04-07T00:04:20.000Z","updated_at":"2024-07-01T19:25:20.000Z","dependencies_parsed_at":"2022-09-01T04:21:34.523Z","dependency_job_id":null,"html_url":"https://github.com/shinnn/coverage","commit_stats":null,"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shinnn%2Fcoverage","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shinnn%2Fcoverage/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shinnn%2Fcoverage/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shinnn%2Fcoverage/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/shinnn","download_url":"https://codeload.github.com/shinnn/coverage/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248125632,"owners_count":21051766,"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":["code-coverage","command-line-tool","coverage-report","ecmascript","javascript","nodejs"],"created_at":"2024-10-18T17:34:25.082Z","updated_at":"2025-04-09T22:54:24.489Z","avatar_url":"https://github.com/shinnn.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# coverage\n\n[![npm version](https://img.shields.io/npm/v/coverage.svg)](https://www.npmjs.com/package/coverage)\n[![Github Actions](https://action-badges.now.sh/shinnn/coverage)](https://wdp9fww0r9.execute-api.us-west-2.amazonaws.com/production/results/shinnn/coverage)\n[![Build Status](https://travis-ci.com/shinnn/coverage.svg?branch=master)](https://travis-ci.com/shinnn/coverage)\n[![Build status](https://ci.appveyor.com/api/projects/status/x5huttqwjqfpl05q/branch/master?svg=true)](https://ci.appveyor.com/project/ShinnosukeWatanabe/coverage/branch/master)\n[![CircleCI](https://circleci.com/gh/shinnn/coverage/tree/master.svg?style=shield)](https://circleci.com/gh/shinnn/coverage/tree/master)\n[![codecov](https://codecov.io/gh/shinnn/coverage/branch/master/graph/badge.svg)](https://codecov.io/gh/shinnn/coverage)\n\nA command-line tool to collect and report code coverage of a JavaScript program\n\n```console\n$ coverage test.js\n\n✔ write a file\n✔ create directories as needed\n✔ validate arguments\n\n3 of 3 passed.\n\n----------|----------|----------|----------|----------|-------------------|\nFile      |  % Stmts | % Branch |  % Funcs |  % Lines | Uncovered Line #s |\n----------|----------|----------|----------|----------|-------------------|\nAll files |    95.15 |    79.52 |      100 |    95.09 |                   |\n index.js |     90.6 |    75.38 |      100 |    90.52 |... 44,148,152,156 |\n lib.js   |      100 |    94.44 |      100 |      100 |               107 |\n----------|----------|----------|----------|----------|-------------------|\n```\n\nThis is an opinionated wrapper of [c8](https://github.com/bcoe/c8), different in the following points:\n\n* Runs both [`html` and `text` reporter](https://github.com/istanbuljs/nyc#running-reports) by default\n* Automatically enables [ECMAScript module](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import) support for `.mjs` files\n* The first argument can be a JavaScript file path instead of a command\n* Built-in [Codecov](https://codecov.io) support\n\n## Installation\n\n[Use](https://docs.npmjs.com/cli/install) [npm](https://docs.npmjs.com/about-npm/).\n\n```\nnpm install coverage\n```\n\nOnce this package is installed to the project directory, users can execute `coverage` command inside [npm scripts](https://docs.npmjs.com/misc/scripts#description).\n\n## CLI\n\n### `coverage [options] \u003cfile|command\u003e [args]`\n\n\u003cimg alt=\"An example of the HTML report\" src=\"screenshot.png\" width=\"330px\" align=\"right\"\u003e\n\nExecute the command, print code coverage to the stdout and write [HTML reports](https://istanbul.js.org/docs/advanced/alternative-reporters/#html) under the `./coverage` directory.\n\n`\u003cfile|command\u003e` can be either a JavaScript file path or a command. If a path is provided, the file is run with the `node` command.\n\n```console\n$ coverage /path/to/entry-point.js # is the same as ↓\n$ coverage node /path/to/entry-point.js\n```\n\nIf the provided JavaScript path ends with `.mjs`,\n\n* [ECMAScript module mode](https://nodejs.org/api/esm.html) is automatically [enabled](https://nodejs.org/api/esm.html#esm_enabling).\n* [`--es-module-specifier-resolution`](https://nodejs.org/api/esm.html#esm_customizing_esm_specifier_resolution_algorithm) is automatically set to `node`.\n\n#### Reporters\n\nUsers can override the default format of reports with `--reporter` option.\n\n```console\n$ coverage example.js\n------------|----------|----------|----------|----------|-------------------|\nFile        |  % Stmts | % Branch |  % Funcs |  % Lines | Uncovered Line #s |\n------------|----------|----------|----------|----------|-------------------|\nAll files   |      100 |      100 |      100 |      100 |                   |\n example.js |      100 |      100 |      100 |      100 |                   |\n------------|----------|----------|----------|----------|-------------------|\n\n$ coverage --reporter=text-summary example.js\n\n=============================== Coverage summary ===============================\nStatements   : 100% ( 1/1 )\nBranches     : 100% ( 1/1 )\nFunctions    : 100% ( 0/0 )\nLines        : 100% ( 1/1 )\n================================================================================\n\n$ coverage --reporter=none example.js # No reports\n```\n\n#### Codecov integration\n\nWhen the execution exits with code `0` on a CI service or [GitHub Actions](https://github.com/features/actions), it automatically uploads the generated coverage to [Codecov](https://docs.codecov.io/docs). Whether `CODECOV_TOKEN` environment variable is required or not varies between [services](https://github.com/codecov/codecov-bash#ci-providers).\n\n```console\n$ coverage test.js\n\n[... test results and coverage ...]\n\n==\u003e Travis CI detected.\n==\u003e Reading reports\n    + /home/travis/build/shinnn/coverage/coverage/lcov.info bytes=1399\n==\u003e Gzipping contents\n==\u003e Uploading reports\n    -\u003e Uploading\n    -\u003e View reports at https://codecov.io/github/shinnn/coverage/commit/e4f5880b8ec5885e6a0b79030df5871e19d6de1d\n```\n\n`c8` command-line [options](https://github.com/bcoe/c8/blob/v3.4.0/lib/parse-args.js#L13-L74) are supported. Run `npx coverage --help` to show the detailed reference for them.\n\n### `coverage report`\n\nOutput a report in the format specified in `--reporter` option.\n\nThis subcommand is only available after `coverage` has already been run.\n\n## License\n\n[ISC License](./LICENSE) © 2019 Shinnosuke Watanabe\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshinnn%2Fcoverage","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshinnn%2Fcoverage","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshinnn%2Fcoverage/lists"}