Skip to content

Conversation

@alexhans1
Copy link

@alexhans1 alexhans1 commented Mar 10, 2025

Hi there,

In our org we would like to set a max value for coverage. Meaning if the coverage is above that value, we no longer bump the thresholds.
This ensures that we set realistic targets that we don't have to adjust downwards all the time.
This would also fix issue #21

This PR adds this ability to jest-it-up.

How it works:

current:

coverageThreshold: {
  global: {
    statements: 60,
    branches: 12,
    functions: 32,
    lines: 34,
  },
}

actual:

coverageThreshold: {
  global: {
    statements: 62,
    branches: 45,
    functions: 70,
    lines: 55,
  },
}

npx jest-it-up --max-threshold 60

new:

coverageThreshold: {
  global: {
    statements: 60,
    branches: 45,
    functions: 60,
    lines: 55,
  },
}

please review it and consider merging it, if you think it adds value.

@rbardini rbardini linked an issue Mar 23, 2025 that may be closed by this pull request
bin/jest-it-up Outdated
Comment on lines 20 to 21
'--max-threshold <max>',
'max value to update the threshold',
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think of renaming it target threshold? Should avoid the min vs max confusion. Also with a short -T flag:

Suggested change
'--max-threshold <max>',
'max value to update the threshold',
'-T, --target <threshold>',
'target threshold to reach',

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

README.md Outdated
-d, --dry-run process but do not change files
-v, --version output the version number
-p, --precision number of threshold decimal places to persist
---max-threshold max value to update the threshold
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please run jest-it-up --help and paste the output here so that the docs match.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Comment on lines 18 to 19
if (nextCoverage > threshold + margin) {
const next = Math.min(nextCoverage, maxThreshold ?? 100)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't we skip updating if nextCoverage is greater than maxThreshold instead?

Suggested change
if (nextCoverage > threshold + margin) {
const next = Math.min(nextCoverage, maxThreshold ?? 100)
if (nextCoverage > threshold + margin && nextCoverage <= maxThreshold) {

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not quite. if the nextCoverage is bigger than the targetThreshold, then we still want to update it to the targetThreshold.

But if the previous threshold was already the target threshold, then we don't need to update it. I added that condition.

@alexhans1 alexhans1 force-pushed the add-max-coverage-option branch from 5d32671 to dad8e2f Compare March 24, 2025 14:17
@alexhans1 alexhans1 closed this Sep 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Minimum coverage?

2 participants