Ember - How to break the build if test coverage fails minimum threshold?

231 views Asked by At

I want to break the build if coverage drops below certain percentage. Currently test runs and coverage is generated if I run below command.

COVERAGE=true ember test

enter image description here

but I don't see a way to break the build based on coverage percentage. Request to help me on this.

1

There are 1 answers

1
fredericrous On

It is sadly not built-in. However, some people were successful setting coverage threshold with Istambul

I attached a picture of the configuration I found at https://github.com/kategengler/ember-cli-code-coverage/issues/23

enter image description here

If you are looking to fail the build in a CI/CD pipeline, an easy alternative road would be to:

  • use grep to parse the generated output that contains the coverage result
  • compare the resulting percentage to your threshold with bc

Note: We are using EmberJS at my company but we don't have coverage thresholds configured on emberjs projects . It's configured on React projects tho because Jest has that built-in