Sajad Norouzi Sajad Norouzi - 8 days ago 6
Node.js Question

jest - Is there a way to check percentage of test coverage?

I used following command to run my tests and get a coverage report:

jest --coverage


now I want to check whether percentage of coverage is more than 90% or not in my script file. what should I do ?

Answer

Try using this options

https://facebook.github.io/jest/docs/configuration.html#coveragethreshold-object

{
  ...
  "jest": {
    "coverageThreshold": {
      "global": {
        "branches": 50,
        "functions": 50,
        "lines": 50,
        "statements": 50
      }
    }
  }
}
Comments