Skip to content

Commit

Permalink
feat(config): support istanbul-api instrumentation configuration
Browse files Browse the repository at this point in the history
Add a configuration option to provide istanbul-api instrumentation configuration
  • Loading branch information
briandipalma committed Jul 24, 2019
1 parent df3d5df commit 401aee6
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 24 deletions.
38 changes: 22 additions & 16 deletions README.md
Expand Up @@ -89,32 +89,38 @@ module.exports = function(config) {
}
},

verbose: true // output config used by istanbul for debugging
verbose: true, // output config used by istanbul for debugging

// `instrumentation` is used to configure Istanbul API package.
instrumentation: {
// To include `node_modules` code in the report.
'default-excludes': false
}
}
});
};
```

### List of reporters and options

* [clover](https://github.com/istanbuljs/istanbuljs/blob/aae256fb8b9a3d19414dcf069c592e88712c32c6/packages/istanbul-reports/lib/clover/index.js#L8-L9)
* [cobertura](https://github.com/istanbuljs/istanbuljs/blob/aae256fb8b9a3d19414dcf069c592e88712c32c6/packages/istanbul-reports/lib/cobertura/index.js#L9-L10)
* [html](https://github.com/istanbuljs/istanbuljs/blob/aae256fb8b9a3d19414dcf069c592e88712c32c6/packages/istanbul-reports/lib/html/index.js#L135-L137)
* [json-summary](https://github.com/istanbuljs/istanbuljs/blob/aae256fb8b9a3d19414dcf069c592e88712c32c6/packages/istanbul-reports/lib/json-summary/index.js#L8)
* [json](https://github.com/istanbuljs/istanbuljs/blob/aae256fb8b9a3d19414dcf069c592e88712c32c6/packages/istanbul-reports/lib/json/index.js#L8)
* lcov
* [lcovonly](https://github.com/istanbuljs/istanbuljs/blob/aae256fb8b9a3d19414dcf069c592e88712c32c6/packages/istanbul-reports/lib/lcovonly/index.js#L8)
* none
* [teamcity](https://github.com/istanbuljs/istanbuljs/blob/aae256fb8b9a3d19414dcf069c592e88712c32c6/packages/istanbul-reports/lib/teamcity/index.js#L9-L10)
* [text-lcov](https://github.com/istanbuljs/istanbuljs/blob/aae256fb8b9a3d19414dcf069c592e88712c32c6/packages/istanbul-reports/lib/text-lcov/index.js#L9)
* [text-summary](https://github.com/istanbuljs/istanbuljs/blob/aae256fb8b9a3d19414dcf069c592e88712c32c6/packages/istanbul-reports/lib/text-summary/index.js#L9)
* [text](https://github.com/istanbuljs/istanbuljs/blob/aae256fb8b9a3d19414dcf069c592e88712c32c6/packages/istanbul-reports/lib/text/index.js#L159-L160)
- [clover](https://github.com/istanbuljs/istanbuljs/blob/aae256fb8b9a3d19414dcf069c592e88712c32c6/packages/istanbul-reports/lib/clover/index.js#L8-L9)
- [cobertura](https://github.com/istanbuljs/istanbuljs/blob/aae256fb8b9a3d19414dcf069c592e88712c32c6/packages/istanbul-reports/lib/cobertura/index.js#L9-L10)
- [html](https://github.com/istanbuljs/istanbuljs/blob/aae256fb8b9a3d19414dcf069c592e88712c32c6/packages/istanbul-reports/lib/html/index.js#L135-L137)
- [json-summary](https://github.com/istanbuljs/istanbuljs/blob/aae256fb8b9a3d19414dcf069c592e88712c32c6/packages/istanbul-reports/lib/json-summary/index.js#L8)
- [json](https://github.com/istanbuljs/istanbuljs/blob/aae256fb8b9a3d19414dcf069c592e88712c32c6/packages/istanbul-reports/lib/json/index.js#L8)
- lcov
- [lcovonly](https://github.com/istanbuljs/istanbuljs/blob/aae256fb8b9a3d19414dcf069c592e88712c32c6/packages/istanbul-reports/lib/lcovonly/index.js#L8)
- none
- [teamcity](https://github.com/istanbuljs/istanbuljs/blob/aae256fb8b9a3d19414dcf069c592e88712c32c6/packages/istanbul-reports/lib/teamcity/index.js#L9-L10)
- [text-lcov](https://github.com/istanbuljs/istanbuljs/blob/aae256fb8b9a3d19414dcf069c592e88712c32c6/packages/istanbul-reports/lib/text-lcov/index.js#L9)
- [text-summary](https://github.com/istanbuljs/istanbuljs/blob/aae256fb8b9a3d19414dcf069c592e88712c32c6/packages/istanbul-reports/lib/text-summary/index.js#L9)
- [text](https://github.com/istanbuljs/istanbuljs/blob/aae256fb8b9a3d19414dcf069c592e88712c32c6/packages/istanbul-reports/lib/text/index.js#L159-L160)

## Credits

* [Original karma-coverage source](https://github.com/karma-runner/karma-coverage/blob/master/lib/reporter.js)
* [Example of using the new reporter API](https://github.com/facebook/jest/blob/master/scripts/mapCoverage.js)
* [Karma remap istanbul](https://github.com/marcules/karma-remap-istanbul)
- [Original karma-coverage source](https://github.com/karma-runner/karma-coverage/blob/master/lib/reporter.js)
- [Example of using the new reporter API](https://github.com/facebook/jest/blob/master/scripts/mapCoverage.js)
- [Karma remap istanbul](https://github.com/marcules/karma-remap-istanbul)

## License

Expand Down
11 changes: 3 additions & 8 deletions src/reporter.js
Expand Up @@ -82,6 +82,7 @@ function CoverageIstanbulReporter(baseReporterDecorator, logger, config) {
: {};

const reportConfig = istanbul.config.loadObject({
instrumentation: Object.assign({}, coverageConfig.instrumentation),
verbose: coverageConfig.verbose === true,
reporting: Object.assign({}, coverageConfig, reportConfigOverride)
});
Expand Down Expand Up @@ -159,9 +160,7 @@ function CoverageIstanbulReporter(baseReporterDecorator, logger, config) {
thresholdCheckFailed = true;
logThresholdMessage(
thresholds,
`Coverage for ${type} (${
globalSummary[type].pct
}%) does not meet global threshold (${thresholds.global[type]}%)`
`Coverage for ${type} (${globalSummary[type].pct}%) does not meet global threshold (${thresholds.global[type]}%)`
);
});

Expand All @@ -188,11 +187,7 @@ function CoverageIstanbulReporter(baseReporterDecorator, logger, config) {

logThresholdMessage(
thresholds,
`Coverage for ${type} (${
fileSummary[type].pct
}%) in file ${file} does not meet per file threshold (${
fileThresholds[type]
}%)`
`Coverage for ${type} (${fileSummary[type].pct}%) in file ${file} does not meet per file threshold (${fileThresholds[type]}%)`
);
});
});
Expand Down

0 comments on commit 401aee6

Please sign in to comment.