feat(coverage): pass previous threshold as second argument to autoUpdate function by wouterkroes · Pull Request #10495 · vitest-dev/vitest (original) (raw)
Description
When coverage.thresholds.autoUpdate is set to a function, the previous threshold value is now passed as the second argument. This allows users to log or track changes, e.g.:
autoUpdate: (newThreshold, previousThreshold) => {
console.log(Updated threshold from <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mrow><mi>p</mi><mi>r</mi><mi>e</mi><mi>v</mi><mi>i</mi><mi>o</mi><mi>u</mi><mi>s</mi><mi>T</mi><mi>h</mi><mi>r</mi><mi>e</mi><mi>s</mi><mi>h</mi><mi>o</mi><mi>l</mi><mi>d</mi></mrow><mi>t</mi><mi>o</mi></mrow><annotation encoding="application/x-tex">{previousThreshold} to </annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord"><span class="mord mathnormal">p</span><span class="mord mathnormal">re</span><span class="mord mathnormal" style="margin-right:0.03588em;">v</span><span class="mord mathnormal">i</span><span class="mord mathnormal">o</span><span class="mord mathnormal">u</span><span class="mord mathnormal">s</span><span class="mord mathnormal" style="margin-right:0.13889em;">T</span><span class="mord mathnormal">h</span><span class="mord mathnormal">res</span><span class="mord mathnormal">h</span><span class="mord mathnormal">o</span><span class="mord mathnormal" style="margin-right:0.01968em;">l</span><span class="mord mathnormal">d</span></span><span class="mord mathnormal">t</span><span class="mord mathnormal">o</span></span></span></span>{newThreshold})
return Math.floor(newThreshold)
}
Resolves #10459
Please don't delete this checklist! Before submitting the PR, please make sure you do the following:
- It's really useful if your PR references an issue where it is discussed ahead of time. If the feature is substantial or introduces breaking changes without a discussion, PR might be closed.
- Ideally, include a test that fails without this PR but passes with it.
- Please, don't make changes to pnpm-lock.yaml unless you introduce a new test example.
- Please check Allow edits by maintainers to make review process faster. Note that this option is not available for repositories that are owned by Github organizations.
Tests
- Run the tests with pnpm test:ci.
Documentation
- If you introduce new functionality, document it. You can run documentation with pnpm run docs command.
Changesets
- Changes in changelog are generated from PR name. Please, make sure that it explains your changes in an understandable manner. Please, prefix changeset messages with feat:, fix:, perf:, docs:, or chore:.