Ratchet up code coverage - keep test coverage going only one direction -- up

Jest-Ratchet is a coverage watcher for Jest. Everytime a new level of coverage is reached Jest-Ratchet will automatically update the coverageThreshold.

Installation

npm

npm install jest-ratchet --dev

yarn

yarn add jest-ratchet --dev

Jest Settings

Add jest-ratchet to the reporters section. And also ensure that collectCoverage is enabled and json-summary is added to the coverageReporters .

{ " collectCoverage " : true , " coverageReporters " : [ " json " , " lcov " , " text " , " clover " , " json-summary " ] , " reporters " : [ " default " , " jest-ratchet " ] }

Optional Settings

By default, Jest-Ratchet is aggressive with updating coverage thresholds. Every time your coverage ticks up by 0.01%, the coverageThreshold is updated. There are a couple of options dampen this behavior.

tolerance (number): keeps the threshold below the measured coverage, allowing wiggle room. default: 0 tolerance

roundDown (boolean): round down to the nearest integer. default: false

timeout (number): the number of milliseconds to wait for to the Jest coverage json summary. default: wait indefinitely

Here's how to pass configuration to Jest-Ratchet, per the Jest documentation