{"id":13807928,"url":"https://github.com/ember-cli-code-coverage/ember-cli-code-coverage","last_synced_at":"2026-03-09T23:03:36.595Z","repository":{"id":8323175,"uuid":"56027663","full_name":"ember-cli-code-coverage/ember-cli-code-coverage","owner":"ember-cli-code-coverage","description":"Code coverage for ember apps using Istanbul","archived":false,"fork":false,"pushed_at":"2024-09-24T13:27:12.000Z","size":2546,"stargazers_count":194,"open_issues_count":47,"forks_count":108,"subscribers_count":12,"default_branch":"master","last_synced_at":"2026-02-12T09:43:06.974Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ember-cli-code-coverage.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":null,"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}},"created_at":"2016-04-12T03:25:50.000Z","updated_at":"2025-10-16T20:26:14.000Z","dependencies_parsed_at":"2024-04-25T17:55:14.020Z","dependency_job_id":"e7b38528-77e0-42b3-853f-d653db8e8926","html_url":"https://github.com/ember-cli-code-coverage/ember-cli-code-coverage","commit_stats":null,"previous_names":["kategengler/ember-cli-code-coverage"],"tags_count":52,"template":false,"template_full_name":null,"purl":"pkg:github/ember-cli-code-coverage/ember-cli-code-coverage","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ember-cli-code-coverage%2Fember-cli-code-coverage","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ember-cli-code-coverage%2Fember-cli-code-coverage/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ember-cli-code-coverage%2Fember-cli-code-coverage/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ember-cli-code-coverage%2Fember-cli-code-coverage/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ember-cli-code-coverage","download_url":"https://codeload.github.com/ember-cli-code-coverage/ember-cli-code-coverage/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ember-cli-code-coverage%2Fember-cli-code-coverage/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30315988,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-09T20:05:46.299Z","status":"ssl_error","status_checked_at":"2026-03-09T19:57:04.425Z","response_time":61,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6: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":"2024-08-04T01:01:32.335Z","updated_at":"2026-03-09T23:03:36.565Z","avatar_url":"https://github.com/ember-cli-code-coverage.png","language":"JavaScript","readme":"# ember-cli-code-coverage\n\n[![npm version](https://badge.fury.io/js/ember-cli-code-coverage.svg)](http://badge.fury.io/js/ember-cli-code-coverage)\n[![CI](https://github.com/kategengler/ember-cli-code-coverage/workflows/CI/badge.svg)](https://github.com/kategengler/ember-cli-code-coverage/actions?query=workflow%3ACI)\n\nCode coverage using [Istanbul](https://github.com/gotwarlost/istanbul) for Ember apps.\n\n## Requirements\n* If using Mocha, Testem `\u003e= 1.6.0` for which you need ember-cli `\u003e 2.4.3`\n* If using Mirage you need `ember-cli-mirage \u003e= 0.1.13`\n* If using Pretender (even as a dependency of Mirage) you need `pretender \u003e= 0.11.0`\n* If using Mirage or Pretender, you need to [set up a passthrough for coverage to be written](#create-a-passthrough-when-intercepting-all-ajax-requests-in-tests).\n* `ember-cli-babel \u003e= 6.0.0`\n\n\n## Installation\n\n* `ember install ember-cli-code-coverage`\n\n## Setup\n\nIn order to gather code coverage information, you must first install the Babel plugins in each project that you'd like to have instrumented.\n\nFor classic apps (ember-cli-build.js):\n\n```js\nlet app = new EmberApp(defaults, {\n  babel: {\n    plugins: [...require('ember-cli-code-coverage').buildBabelPlugin()],\n  },\n});\n```\n\nFor embroider apps (ember-cli-build.js):\n\n```js\nlet app = new EmberApp(defaults, {\n  babel: {\n    plugins: [...require('ember-cli-code-coverage').buildBabelPlugin({ embroider: true })],\n  },\n});\n```\n\nFor in-repo and standalone addons (index.js):\n\n```js\nmodule.exports = {\n  name: require('./package').name,\n\n  options: {\n    babel: {\n      plugins: [...require('ember-cli-code-coverage').buildBabelPlugin()],\n    },\n  },\n};\n```\n\nFor in-repo engines (index.js):\n\n```js\nmodule.exports = EngineAddon.extend({\n  // ...\n  included() {\n    this._super.included.apply(this, arguments);\n    this.options.babel.plugins.push(...require('ember-cli-code-coverage').buildBabelPlugin());\n  },\n});\n```\n\nFor `app` files in standalone addons (ember-cli-build.js):\n\n```js\nlet app = new EmberAddon(defaults, {\n  babel: {\n    plugins: [...require('ember-cli-code-coverage').buildBabelPlugin()]\n  },\n});\n```\n\ntests/test-helpers.js:\n```js\nimport { forceModulesToBeLoaded, sendCoverage } from 'ember-cli-code-coverage/test-support';\nimport Qunit from 'qunit';\n\nQUnit.done(async function() {\n  forceModulesToBeLoaded();\n  await sendCoverage();\n});\n```\n\n## Usage\n\nCoverage will only be generated when an [environment variable](https://en.wikipedia.org/wiki/Environment_variable) is true (by default `COVERAGE`) and running your test command like normal.\n\nFor example:\n\n`COVERAGE=true ember test`\n\nIf you want your coverage to work on both Unix and Windows, you can do this:\n\n`npm install cross-env --save-dev`\n\nand then:\n\n`cross-env COVERAGE=true ember test`\n\nWhen running with `parallel` set to true, the final reports can be merged by using `ember coverage-merge`. The final merged output will be stored in the `coverageFolder`.\n\nIf you intend to use `ember test` with the `--path` flag, you should generate the build\nwith `coverageEnvVar` set as true. This is because the code is instrumented for\ncoverage during the build.\n\nFor example:\n\n`COVERAGE=true ember build --environment=test --output-path=dist`\n\nfollowed by\n\n`COVERAGE=true ember test --path=dist`\n\n## TypeScript integration\n\nSteps:\n\n* in `tsconfig.json`\n```js\n  {\n    \"compilerOptions\": {\n      \"inlineSourceMap\": true,\n      \"inlineSources\": true\n    }\n  }\n```\n* in `ember-cli-build.js`\n```js\n  const app = new EmberApp(defaults, {\n    babel: {\n      sourceMaps: 'inline'\n    },\n    sourcemaps: {\n      enabled: true,\n      extensions: ['js']\n    }\n  });\n```\n* in `package.json` specify latest available version\n```js\n  {\n    devDependencies: {\n      \"ember-cli-code-coverage\": \"^2.1.0\",\n    }\n  }\n```\n## ember-template-imports integration\n\n* in `ember-cli-build.js\n```\n  const app = new EmberApp(defaults, {\n    'ember-template-imports': {\n      inline_source_map: true,\n    },\n  });\n```\n\n## Configuration\n\nConfiguration is optional. It should be put in a file at `config/coverage.js` (`configPath` configuration in package.json is honored). In addition to this you can configure Istanbul by adding a `.istanbul.yml` file to the root directory of your app (See https://github.com/gotwarlost/istanbul#configuring)\n\n#### Options\n\n- `coverageEnvVar`: Defaults to `COVERAGE`. This is the environment variable that when set will cause coverage metrics to be generated.\n\n- `reporters`: Defaults to `['lcov', 'html']`. The `json-summary` reporter will\n  be added to anything set here, it is required. This can be any [reporters\n  supported by\n  Istanbul](https://github.com/gotwarlost/istanbul/tree/master/lib/report).\n  Reporters can be configured with array-style syntax, for example, here are\n  options to `lcov` with a different `projectRoot`: `[['lcov', { projectRoot:\n  '/packages/addon' }], 'html']`\n\n- `excludes`: Defaults to `['*/mirage/**/*']`. An array of globs to exclude from instrumentation. Useful to exclude files from coverage statistics.\n\n- `extension`: Defaults to `['.gjs', '.gts', '.js', '.ts', '.cjs', '.mjs', '.mts', '.cts']`. Tell Istanbul to instrument only files with the provided extensions.\n\n- `coverageFolder`: Defaults to `coverage`. A folder relative to the root of your project to store coverage results.\n\n- `parallel`: Defaults to `false`. Should be set to true if parallel testing is being used for separate test runs, for example when using [ember-exam](https://github.com/trentmwillis/ember-exam) with the `--partition` flag. This will generate the coverage reports in directories suffixed with `_\u003crandom_string\u003e` to avoid overwriting other threads reports. These reports can be joined by using the `ember coverage-merge` command (potentially as part of the [posttest hook](https://docs.npmjs.com/misc/scripts) in your `package.json`).\n\n- `modifyAssetLocation`: Optional function that will allow you to override where a file actually lives inside of your project. See [Advanced customization](#modifyassetlocation) on how to use this function in practice.\n\n#### Example\n```js\n  module.exports = {\n    coverageEnvVar: 'COV'\n  }\n```\n\n## Create a passthrough when intercepting all ajax requests in tests\n\nTo work, this addon has to post coverage results back to a middleware at `/write-coverage`.\n\nIf you are using [`ember-cli-mirage`](http://www.ember-cli-mirage.com) you should add the following:\n\n```\n// in mirage/config.js\n\n  this.passthrough('/write-coverage');\n  this.namespace = 'api';  // It's important that the passthrough for coverage is before the namespace, otherwise it will be prefixed.\n```\n\nIf you are using [`ember-cli-pretender`](https://github.com/rwjblue/ember-cli-pretender) you should add the following:\n\n```\n// where ever you set up the Pretender Server\n\n  var server = new Pretender(function () {\n    this.post('/write-coverage', this.passthrough);\n  });\n```\n\n## Advanced customization\n\n### `forceModulesToBeLoaded`\n\nThe `forceModulesToBeLoaded` function can potentially cause unintended side effects when executed. You can pass custom filter fuctions that allow\nyou to specify which modules will be force loaded or not:\n\n```js\nQUnit.done(async () =\u003e {\n  // type will be either webpack and/or require\n  forceModulesToBeLoaded((type, moduleName) =\u003e { return true; });\n  await sendCoverage();\n});\n```\n\n### `modifyAssetLocation`\n\nUnder the hood, `ember-cli-code-coverage` attempts to \"de-namespacify\" paths into their real on disk location inside of\n`project.root` (ie give a namespaced path like lib/inrepo/components/foo.js would live in lib/inrepo/addon/components/foo.js). It makes\nsome assumptions (where files live in in-repo addons vs app code for example) and sometimes those assumptions might not hold. Passing a\nfunction `modifyAssetLocation` in your [configuration file](#configuration) will allow you to override where a file actually lives inside\nof your project. The returned string should be relative to your project root.\n\n```js\nmodule.exports = {\n  modifyAssetLocation(root, relativePath) {\n    let appPath = relativePath.replace('my-project-name', 'app');\n\n    // here is an example of saying that `app/components/foo.js` actually\n    // lives in `lib/inrepo/app/components/foo.js` on disk.\n    if (fs.existsSync(path.join(root, 'lib', 'inrepo', appPath))) {\n      return path.join('lib', 'inrepo', appPath);\n    }\n\n    return false;\n  },\n};\n```\n\n## Inspiration\n\nThis addon was inspired by [`ember-cli-blanket`](https://github.com/sglanzer/ember-cli-blanket).\nThe primary differences are that this addon uses Istanbul rather than Blanket for coverage and it instruments your application code as part of the build, when enabled.\n","funding_links":[],"categories":["Packages"],"sub_categories":["Testing"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fember-cli-code-coverage%2Fember-cli-code-coverage","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fember-cli-code-coverage%2Fember-cli-code-coverage","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fember-cli-code-coverage%2Fember-cli-code-coverage/lists"}