From 401aee6c4d5f9e1a48097b3a0be7677654af7d7b Mon Sep 17 00:00:00 2001 From: Brian Di Palma Date: Mon, 15 Jul 2019 16:17:50 +0100 Subject: [PATCH] feat(config): support istanbul-api instrumentation configuration Add a configuration option to provide istanbul-api instrumentation configuration --- README.md | 38 ++++++++++++++++++++++---------------- src/reporter.js | 11 +++-------- 2 files changed, 25 insertions(+), 24 deletions(-) diff --git a/README.md b/README.md index 1c906ea..4de6df1 100644 --- a/README.md +++ b/README.md @@ -89,7 +89,13 @@ 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 + } } }); }; @@ -97,24 +103,24 @@ module.exports = function(config) { ### 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 diff --git a/src/reporter.js b/src/reporter.js index c4eaf7d..7d4e665 100644 --- a/src/reporter.js +++ b/src/reporter.js @@ -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) }); @@ -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]}%)` ); }); @@ -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]}%)` ); }); });