Skip to content

Commit

Permalink
Improve coverage threshold value (#9023)
Browse files Browse the repository at this point in the history
* Improve coverage threshold value

* Fix typespec

* Fix linter

* FIx typespec of threshold
  • Loading branch information
yordis authored and jeysal committed Oct 13, 2019
1 parent 1d4bd5f commit 309d95a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
4 changes: 2 additions & 2 deletions packages/jest-reporters/src/coverage_reporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ export default class CoverageReporter extends BaseReporter {
if (globalConfig.coverageThreshold) {
function check(
name: string,
thresholds: {[index: string]: number},
thresholds: Config.CoverageThresholdValue,
actuals: istanbulCoverage.CoverageSummaryData,
) {
return (['statements', 'branches', 'lines', 'functions'] as Array<
Expand All @@ -226,7 +226,7 @@ export default class CoverageReporter extends BaseReporter {
const actualUncovered = actuals[key].total - actuals[key].covered;
const threshold = thresholds[key];

if (threshold != null) {
if (threshold !== undefined) {
if (threshold < 0) {
if (threshold * -1 < actualUncovered) {
errors.push(
Expand Down
15 changes: 9 additions & 6 deletions packages/jest-types/src/Config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -278,13 +278,16 @@ type DisplayNameColor =
| 'bgCyanBright'
| 'bgWhiteBright';

export type CoverageThresholdValue = {
branches?: number;
functions?: number;
lines?: number;
statements?: number;
};

type CoverageThreshold = {
[path: string]: {
[key: string]: number;
};
global: {
[key: string]: number;
};
[path: string]: CoverageThresholdValue;
global: CoverageThresholdValue;
};

export type GlobalConfig = {
Expand Down

0 comments on commit 309d95a

Please sign in to comment.