Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,9 @@ Configuration is optional. It should be put in a file at `config/coverage.js` (`
options to `lcov` with a different `projectRoot`: `[['lcov', { projectRoot:
'/packages/addon' }], 'html']`

- `includes`: Defaults to `['**/*']`. An array of globs to include in
instrumentation. Sometimes its more useful to constrain `includes` over using `excludes`.

- `excludes`: Defaults to `['*/mirage/**/*']`. An array of globs to exclude from instrumentation. Useful to exclude files from coverage statistics.

- `extension`: Defaults to `['.gjs', '.gts', '.js', '.ts', '.cjs', '.mjs', '.mts', '.cts']`. Tell Istanbul to instrument only files with the provided extensions.
Expand Down
7 changes: 6 additions & 1 deletion packages/ember-cli-code-coverage/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ module.exports = {
*/
buildBabelPlugin(opts = {}) {
let cwd = opts.cwd || process.cwd();
let include = ['**/*'];
let exclude = ['*/mirage/**/*', '*/node_modules/**/*'];
let extension = [
'.gjs',
Expand All @@ -51,6 +52,10 @@ module.exports = {
if (fs.existsSync(path.join(cwd, configBase, 'coverage.js'))) {
let config = require(path.join(cwd, configBase, 'coverage.js'));

if (config.includes) {
include = config.includes;
}

if (config.excludes) {
exclude = config.excludes;
}
Expand Down Expand Up @@ -89,7 +94,7 @@ module.exports = {
return [
// String lookup is needed to workaround https://github.com/embroider-build/embroider/issues/1525
path.resolve(__dirname, 'lib/gjs-gts-istanbul-ignore-template-plugin'),
[IstanbulPlugin, { cwd, include: '**/*', exclude, extension }],
[IstanbulPlugin, { cwd, include, exclude, extension }],
];
},

Expand Down
Loading