Jest dynamically adjust coverage threshold

Viewed 136

I have added jest to my teams frontend development pipeline. Right now the coverage is really low, about 1.2%, and the goal is to make sure we keep growing -- E.g with every commit code coverage at least does not decrease.

I was able to set up jest to check code coverage

collectCoverage: true,
    collectCoverageFrom: [
        "<rootDir>/src/**/*.{ts,tsx}",
    ],
    coverageThreshold: {
        global: {
            "statements": 1.26,
            "branches": 1.32,
            "functions": 1.1,
            "lines": 1.25,
        },
    },

but as you can see those values are static, and I would have to manually update them as we improve our coverage.

Is there a way to tell jest to check that the new code coverage is better than the one before the changes being pushed ?

0 Answers
Related