Skip to content

Commit

Permalink
fix: improve readability for coverage check logic (#403)
Browse files Browse the repository at this point in the history
  • Loading branch information
vladjerca authored Sep 10, 2020
1 parent 7c41300 commit 8b8f14a
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions packages/karma-typescript/src/karma/reporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,7 @@ export class Reporter {
const browsers: any[] = [];
collection.forEach((browser) => browsers.push(browser));

let isBelowCoverageThreshold = false;

for(const browser of browsers) {
const coverageChecks = browsers.map(async (browser) => {
const coverage = that.coverageMap.get(browser);
const coverageMap = istanbulCoverage.createCoverageMap();
coverageMap.merge(coverage);
Expand Down Expand Up @@ -83,14 +81,18 @@ export class Reporter {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
.execute(context);
});

const isCoverageCheckFailed = results && config.hasCoverageThreshold && !threshold.check(browser, remappedCoverageMap);
});

return results
&& config.hasCoverageThreshold
&& !threshold.check(browser, remappedCoverageMap);
});

isBelowCoverageThreshold = isBelowCoverageThreshold || isCoverageCheckFailed;
}
const isCoverageCheckFailed = (await Promise.all(coverageChecks))
.some(isCheckFailed => isCheckFailed);

if (isBelowCoverageThreshold) {
if (isCoverageCheckFailed) {
process.exit(1);
}
};
Expand Down

0 comments on commit 8b8f14a

Please sign in to comment.