Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 ?

like image 392
Sajad Norouzi Avatar asked Nov 24 '16 20:11

Sajad Norouzi


1 Answers

You can use the coverageThreshold option in your Jest configuration:

https://jestjs.io/docs/en/configuration#coveragethreshold-object

{
  ...
  "jest": {
    "coverageThreshold": {
      "global": {
        "branches": 50,
        "functions": 50,
        "lines": 50,
        "statements": 50
      }
    }
  }
}
like image 80
Lucas Katayama Avatar answered Oct 26 '22 16:10

Lucas Katayama