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:

Tests

Documentation

Changesets