Code Coverage

You can upload your code coverage results to Codeac to view detailed coverage metrics alongside static analysis issues. By defining coverage thresholds, you can ensure consistent test quality and enforce them as part of your commit status checks.

Code Coverage support

The Code Coverage feature is currently in beta testing.

Supported lanugages

  • JavaScript
  • TypeScript

Generate LCOV from your Test Framework

First, start generating lcov files from your test framework. Here are a couple of tips for popular frameworks: Code Coverage in Codeac.

Generate a Token for Accessing the Repository from CI

In Codeac, in repository settings, generate a $TOKEN. Save $TOKEN as a secret in your CI environment.

Generate Token in Codeac

Upload Code Coverage to Codeac in your CI pipeline

You can upload your coverage report to Codeac from your CI pipeline. Below is a command that securely uploads the report using your repository token and metadata from your Git commit and branch.

code-coverage-command.sh

curl -X POST -H "x-repository-token: $TOKEN" \
--data-binary @<yourCoverageOutputPath>/lcov.info \
"https://api.codeac.io/v1/coverage/$(git rev-parse HEAD)?branch=$(git rev-parse --abbrev-ref HEAD)&language=JavaScript" \
|| true

View Code Coverage in Codeac

After successfully uploading code coverage, you can view in several places:

  • Dashboard
  • Commit Detail
  • Thresholds

Code Coverage in Codeac

Codeac and your CI pipeline run in parallel, so code quality and coverage results may appear in the UI at different times. It can take a few minutes for all results to show up.

Setting up Thresholds

By specifying a minimum coverage threshold in your .codeac.yml, you can ensure that your team maintains an acceptable level of test coverage.

.codeac.yml

version: '1'

thresholds:
    coveredBranches: 70
    coveredFunctions: 75
    coveredLines: 80

To learn more about Code Coverage Thresholds, check out the documentation.