| 226 | |
| 227 | if (coverageThreshold) { |
| 228 | function check( |
| 229 | name: string, |
| 230 | thresholds: Config.CoverageThresholdValue, |
| 231 | actuals: istanbulCoverage.CoverageSummaryData, |
| 232 | ) { |
| 233 | return ( |
| 234 | ['statements', 'branches', 'lines', 'functions'] as Array< |
| 235 | keyof istanbulCoverage.CoverageSummaryData |
| 236 | > |
| 237 | ).reduce<Array<string>>((errors, key) => { |
| 238 | const actual = actuals[key].pct; |
| 239 | const actualUncovered = actuals[key].total - actuals[key].covered; |
| 240 | const threshold = thresholds[key]; |
| 241 | |
| 242 | if (threshold !== undefined) { |
| 243 | if (threshold < 0) { |
| 244 | if (threshold * -1 < actualUncovered) { |
| 245 | errors.push( |
| 246 | `Jest: Uncovered count for ${key} (${actualUncovered}) ` + |
| 247 | `exceeds ${name} threshold (${-1 * threshold})`, |
| 248 | ); |
| 249 | } |
| 250 | } else if (actual < threshold) { |
| 251 | errors.push( |
| 252 | `Jest: Coverage for ${key} (${actual}%) does not meet "${name}" threshold (${threshold}%)`, |
| 253 | ); |
| 254 | } |
| 255 | } |
| 256 | return errors; |
| 257 | }, []); |
| 258 | } |
| 259 | |
| 260 | const THRESHOLD_GROUP_TYPES = { |
| 261 | GLOB: 'glob', |