-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
and coverage.perFile
Conflict
#3179
Comments
@michaelfaith is this |
Ah, I should have specified. I've only tried this with import { defineConfig } from 'vitest/config'
export default defineConfig({
test: {
root: 'src',
reporters: ['default', 'junit'],
outputFile: {
junit: 'junit.xml',
},
coverage: {
provider: 'c8',
enabled: true,
thresholdAutoUpdate: true,
reporter: ['text', 'json-summary', 'html', 'cobertura'],
statements: 97,
branches: 83,
perFile: true,
},
clearMocks: true,
},
}); |
This looks like a bug, or a missing feature. Both providers are affected. The
Similarly as done here in threshold checking: vitest/packages/coverage-istanbul/src/provider.ts Lines 172 to 183 in baf902a
|
Thanks for the analysis / confirmation |
Thanks for the quick turnaround on this! |
Describe the bug
We're pretty strict on our unit testing goals, and have our thresholds applied at the per file, level, but we'd also like to take advantage of the really nice auto updating feature for continuous improvement. However, when using
coverage.thresholdAutoUpdate
, the thresholds are bumped to corresponding with the global coverage achieved, and not the lowest file coverage achieved for each metric. Ifcoverage.perFile
is set, the auto update should use the lowest individual file coverage for each of the four metrics, rather than the global coverage for its update. With this conflict, there's no way to use both together. The first test run will raise the threshold higher than the lowest individual file coverage, which results in a failed test run the second time. We have to disable the auto update, when usingperFile
e.g. in this example, the statement and branch thresholds should be set to 97.2 and 83.33, but instead are being set to 99.5, and 92.59
I searched existing issues for this, and don't see anything related to it.
Reproduction
Generating coverage folder doesn't seem to work in stackblitz? Hopefully, the description is thorough enough.
System Info
Used Package Manager
yarn
Validations
The text was updated successfully, but these errors were encountered: