{"id":24598466,"url":"https://github.com/origin-1/c8js","last_synced_at":"2026-03-04T13:05:35.424Z","repository":{"id":57685217,"uuid":"478851710","full_name":"origin-1/c8js","owner":"origin-1","description":"A modern, asynchronous Node.js API for c8","archived":false,"fork":false,"pushed_at":"2025-09-04T16:48:10.000Z","size":185,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-01-31T11:46:14.912Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://origin-1.github.io/c8js/","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/origin-1.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":"2022-04-07T06:16:00.000Z","updated_at":"2025-09-04T16:47:30.000Z","dependencies_parsed_at":"2024-03-23T12:16:02.141Z","dependency_job_id":"5d34d87a-198c-4514-87aa-5627ee7798d8","html_url":"https://github.com/origin-1/c8js","commit_stats":null,"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"purl":"pkg:github/origin-1/c8js","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/origin-1%2Fc8js","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/origin-1%2Fc8js/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/origin-1%2Fc8js/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/origin-1%2Fc8js/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/origin-1","download_url":"https://codeload.github.com/origin-1/c8js/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/origin-1%2Fc8js/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30081205,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-04T12:28:08.313Z","status":"ssl_error","status_checked_at":"2026-03-04T12:27:28.210Z","response_time":59,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: 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":[],"created_at":"2025-01-24T12:16:33.771Z","updated_at":"2026-03-04T13:05:35.397Z","avatar_url":"https://github.com/origin-1.png","language":"JavaScript","readme":"# c8js\n\nA modern, asynchronous Node.js API for [c8](https://github.com/bcoe/c8).\n\n[![npm version][npm badge]][npm url]\n\nc8 leverages Node.js built-in [V8 JavaScript code coverage](https://v8.dev/blog/javascript-code-coverage) to produce [Istanbul](https://istanbul.js.org/)-compatible reports.\n\nc8js offers a usable API to access all c8 commands programmatically in Node.js with JavaScript functions.\n\nc8js is not a wrapper around the command line interface: it calls c8 library functions in the current thread instead of spawning an instrumenter process.\n\n![Comparison without/with c8js](comparison.svg)\n\n## Installation\n\nUse [`npm install`](https://docs.npmjs.com/cli/install):\n\n`npm i -D c8js`\n\n## Usage\n\nc8js exports the functions [`c8js`](https://origin-1.github.io/c8js/modules.html#default) (the default export), [`report`](https://origin-1.github.io/c8js/modules.html#report), and [`checkCoverage`](https://origin-1.github.io/c8js/modules.html#checkcoverage), in place of the commands `c8`, `c8 report`, and `c8 check-coverage` respectively.\nAdditionally, c8js exports the function [`exec`](https://origin-1.github.io/c8js/modules.html#exec) that just runs a command and saves V8 coverage data.\n\nWhile c8 commands accept inline arguments, c8js functions accept in-code options.\nAll [c8js options](https://origin-1.github.io/c8js/interfaces/default.Options.html) can be used in-code with all functions, but some options are only relevant to some of the functions.\nIn-code options override options defined in .c8rc or another configuration file.\n\nAn important difference is that all c8js functions throw exceptions in situations where c8 commands would terminate the process with a nonzero exit code.\n\nFor detailed usage information, see the [**API documentation**](https://origin-1.github.io/c8js/modules).\n\n## Examples\n\n### Run Mocha\n\nThis will run `mocha --check-leaks --timeout=10000 test/*.spec.js` and produce `html` and `text-summary` coverage reports.\n\n```js\nasync function runMocha()\n{\n    const { default: c8js } = await import('c8js');\n    await c8js\n    (\n        'node_modules/mocha/bin/mocha.js',\n        ['--check-leaks', '--timeout=10000', 'test/*.spec.js'],\n        { reporter: ['html', 'text-summary'] },\n    );\n}\n```\n\n### Run with `npx`\n\nSimilar to the previous example, but uses `npx` to locate and run Mocha.\n`npx` will download packages from the npm registry if necessary.\n\n```js\nasync function runMocha()\n{\n    const { default: c8js, commands } = await import('c8js');\n    await c8js\n    (\n        commands.npx,\n        ['mocha', '--check-leaks', '--timeout=10000', 'test/*.spec.js'],\n        { reporter: ['html', 'text-summary'] },\n    );\n}\n```\n\n### Run `npm test`\n\nThis will run `npm test` with the default coverage options.\n\n```js\nasync function runTest()\n{\n    const { default: c8js, commands } = await import('c8js');\n    await c8js(commands.npm, ['test']);\n}\n```\n\n### Run `node --test` (Node.js ≥ 18.1)\n\nNode.js 18.1 introduces the command line flag `--test` that launches the built-in [Test runner](https://nodejs.org/dist/latest/docs/api/test.html).\nThe following function shows how to run `node --test` with default coverage options.\n\n```js\nasync function runTest()\n{\n    const { default: c8js } = await import('c8js');\n    await c8js(process.execPath, ['--test']);\n}\n```\n\n**NOTE:** Some versions of Node.js contain [a bug](https://github.com/nodejs/node/issues/45013) that causes `node --test` to crash when run from c8.\nThe affected Node.js versions are 18.11.0, 18.12.0, 18.12.1, 19.0.0 and 19.0.1.\n\n### Sharing Options\n\nTo use c8js in different build scripts or packages with similar settings, it is useful to export a function that calls c8js with the set of shared options.\nThis function can be imported by each build script and invoked with specific parameters.\n\n```js\n// create-coverage.js\nexport async function createCoverage(options)\n{\n    const { default: c8js, commands } = await import('c8js');\n    await c8js\n    (\n        commands.npm,\n        ['test'],\n        {\n            all:            true,\n            src:            'lib',\n            throwExecError: 'late',\n            watermarks:\n            {\n                branches:   [90, 100],\n                functions:  [90, 100],\n                lines:      [90, 100],\n                statements: [90, 100],\n            },\n            ...options,\n        }\n    );\n}\n```\n\n```js\n// build.js\nimport { createCoverage } from './create-coverage.js';\n\nawait createCoverage({ src: ['lib', 'src/app'], timeout: 300 * 1000 });\n```\n\n## Compatibility\n\nc8js requires Node.js 16 or later.\nThe minimum supported c8 version is 8.0.0.\n\n[npm badge]: https://img.shields.io/npm/v/c8js?logo=npm\n[npm url]: https://www.npmjs.com/package/c8js\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Forigin-1%2Fc8js","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Forigin-1%2Fc8js","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Forigin-1%2Fc8js/lists"}