-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
Labels
feat: coverageIssues and PRs related to the coverage featureIssues and PRs related to the coverage feature
Description
Describe the bug
vitest/packages/vitest/src/utils/coverage.ts
Lines 32 to 38 in eac7776
| for (const key of THRESHOLD_KEYS) { | |
| const threshold = thresholds[key] || 100 | |
| const actual = Math.min(...summaries.map(summary => summary[key].pct)) | |
| if (actual > threshold) | |
| thresholdsToUpdate.push([key, actual]) | |
| } |
thresholds hold the current configuration for the limits; if it is set to zero, then thresholds[key] || 100 evaluates to 100.
As I understand, the logic here is not to update when the value was not set in the configuration in the first place.
?? should be used instead of || as only undefined should become 100, and 0 should stay 0.
Reproduction
This is easy enough to understand without a reproduction repository.
Simple test on playcode https://playcode.io/1624061
System Info
System:
OS: Windows 10 10.0.22621
CPU: (20) x64 12th Gen Intel(R) Core(TM) i7-12700KF
Memory: 52.94 GB / 95.86 GB
Binaries:
Node: 20.8.0 - C:\Program Files\nodejs\node.EXE
Yarn: 1.22.5 - ~\AppData\Roaming\npm\yarn.CMD
npm: 10.1.0 - C:\Program Files\nodejs\npm.CMD
Browsers:
Chrome: 117.0.5938.134
Edge: Spartan (44.22621.2283.0), Chromium (117.0.2045.60)
Internet Explorer: 11.0.22621.1
npmPackages:
@vitest/coverage-v8: ^0.34.1 => 0.34.1
@vitest/ui: ^0.34.5 => 0.34.5
vitest: ^0.34.1 => 0.34.1Used Package Manager
yarn
Validations
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
- The provided reproduction is a minimal reproducible example of the bug.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
feat: coverageIssues and PRs related to the coverage featureIssues and PRs related to the coverage feature