0

I have some jest tests and I can determine the coverage with

jest --coverage

Also see Code coverage for Jest

I automatically execute the tests on a build server (gitlab runner) and want that my tests fail if the coverage is below a certain limit.

In python there is a flag --cov-fail-under that can be used with pytest, e.g.

pytest --cov src --cov-fail-under=90 --cov-report=term

Unfortunately, I could not find a corresponding option for jest.

=>What is the recommended way to check the total coverage?

Should I write some extra script to evaluate the generated json coverage file or is there an easier solution like a specific reporter to use?

skyboyer
  • 22,209
  • 7
  • 57
  • 64
Stefan
  • 10,010
  • 7
  • 61
  • 117

1 Answers1

3

Not listed under CLI-Options, but there is coverageThreshold, which can be used in package.json or within an extra jest configuration file:

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

Stefan
  • 10,010
  • 7
  • 61
  • 117