node.jsreactjsbamboo

NPM coverage threshold - settings


I am running npm coverage test and would like to set the coverage threshold. May i know how to do it ???

I am currently running it as a bamboo plan as something like below :-

cd ${bamboo.build.working.directory}/XXX
npm install react-scripts
npm run coverage

I would like to add the Coverage threshold here. Could you please help me on this ??

Thank you.


Solution

  • You can follow the create-react-app guide for coverage configuration, since it uses react-scripts under the hood. From the docs:

    The default Jest coverage configuration can be overridden by adding any of the following supported keys to a Jest config in your package.json.

    Basically, add the config under jest property in your package.json, something like

    "jest": {
      "coverageThreshold": {
        "global": {
          "branches": 90,
          "functions": 90,
          "lines": 90,
          "statements": 90
        }
      }
    }