Skip to main content
Extend your GitHub Actions CI/CD pipeline to include code coverage analysis alongside unit testing. This guide shows how to:
  • Mirror your existing unit testing setup
  • Add a parallel code-coverage job
  • Archive coverage reports even on failures

1. Reference: Unit Testing Job

Here’s the baseline unit-testing job in .github/workflows/ci.yml:

2. Add a Parallel Code Coverage Job

Below is the code-coverage job that runs side by side with your unit tests:

3. Job Comparison

4. Observe Workflow Runs

After pushing your changes, both jobs appear in the GitHub Actions UI:
The image shows a GitHub Actions page for a project called "Solar System Workflow," displaying a list of workflow runs with their statuses and details.

5. Handling Coverage Threshold Failures

If coverage falls below your defined threshold, the npm run coverage step will fail:
The image shows a GitHub Actions workflow summary with successful unit tests but a failed code coverage check, as the coverage did not meet the required threshold.
By default, a failing coverage step halts the workflow and skips artifact upload.
To ensure your coverage report is always archived, consider:
  • Adding continue-on-error: true to the coverage step
  • Lowering your coverage thresholds in nyc configuration

6. Next Steps

Watch Video