I have a react project published to GitHub, and trying to set up GitHub Actions.
I want to add one step to check if the unit test coverage passes 65% (have to pass it to go through CI/CD process successfully).
This is what I've tried:
build:
name: Test
steps:
- name: Coverage
run: npm run jest-coverage
I need help on following items:
Assuming that your npm script jest-coverage
runs jest with coverage enabled
Requiring 65% test coverage can be achieved with the jest configuration coverageThreshold.
Add this to your jest.config.js
:
{
...
"jest": {
"coverageThreshold": {
"global": {
"branches": 65,
"functions": 65,
"lines": 65,
"statements": 65
}
}
}
}
As for re-running your job when new code is pushed, you want to trigger your workflow on push
, like so:
on: push
jobs:
...
Depending on how you're working with branches and pull requests, the push
could also be replaced with pull_request
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With