Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

coverage.thresholdAutoUpdate does not work when starting from zero #4286

Closed
6 tasks done
krystian-lieber opened this issue Oct 10, 2023 · 0 comments · Fixed by #4287
Closed
6 tasks done

coverage.thresholdAutoUpdate does not work when starting from zero #4286

krystian-lieber opened this issue Oct 10, 2023 · 0 comments · Fixed by #4287
Labels
feat: coverage Issues and PRs related to the coverage feature

Comments

@krystian-lieber
Copy link

krystian-lieber commented Oct 10, 2023

Describe the bug

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.1

Used Package Manager

yarn

Validations

@AriPerkkio AriPerkkio added bug feat: coverage Issues and PRs related to the coverage feature and removed pending triage labels Oct 10, 2023
@github-actions github-actions bot locked and limited conversation to collaborators Nov 7, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feat: coverage Issues and PRs related to the coverage feature
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants