diff --git a/CHANGELOG.md b/CHANGELOG.md index b305af5..e70a452 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,8 @@ All notable changes to this project will be documented in this file. See [standa * node 6 and node 8 are no longer supported. To use this package you must upgrade to node 10 or higher. +* If using threshold reporting and the programmatic karma api, then the exitCode will no longer be returned as 1 when thresholds are not met. + ### Features * upgrade to latest istanbul api ([28cbbfb](https://github.com/mattlewis92/karma-coverage-istanbul-reporter/commit/28cbbfb2cf8bd5b9533ceb489cc5047ff3def730)) @@ -217,4 +219,4 @@ All notable changes to this project will be documented in this file. See [standa # 0.1.0 -* Initial release \ No newline at end of file +* Initial release diff --git a/src/reporter.js b/src/reporter.js index be106ce..15c67e7 100644 --- a/src/reporter.js +++ b/src/reporter.js @@ -74,7 +74,7 @@ function CoverageIstanbulReporter(baseReporterDecorator, logger, config) { } } - async function createReport(browserOrBrowsers, results) { + async function createReport(browserOrBrowsers) { const reportConfigOverride = !coverageConfig.combineBrowserReports && coverageConfig.dir ? { @@ -196,8 +196,10 @@ function CoverageIstanbulReporter(baseReporterDecorator, logger, config) { }); }); - if (thresholdCheckFailed && results && !thresholds.emitWarning) { - results.exitCode = 1; + if (thresholdCheckFailed && !thresholds.emitWarning && config.singleRun) { + process.on('exit', () => { + process.exit(1); + }); } } @@ -226,15 +228,13 @@ function CoverageIstanbulReporter(baseReporterDecorator, logger, config) { }; const baseReporterOnRunComplete = this.onRunComplete; - this.onRunComplete = async function (browsers, results) { + this.onRunComplete = async function (browsers) { Reflect.apply(baseReporterOnRunComplete, this, arguments); if (coverageConfig.combineBrowserReports) { - await createReport(browsers, results); + await createReport(browsers); } else { - await Promise.all( - browsers.map((browser) => createReport(browser, results)) - ); + await Promise.all(browsers.map((browser) => createReport(browser))); } }; }