Code Coverage Tags
Coverage Tags
Coverage tags enable you to report on and gate pull requests based on specific subsets of your code coverage reports. This feature is particularly valuable in complex codebases where different components, languages, or test types need to be tracked separately.
Why Use Coverage Tags?
Tags solve several common challenges when working with code coverage:
- Monorepos and multi-language projects: Track coverage separately for frontend vs. backend code, or for different components in a monorepo
- Different test types: Separate unit tests, integration tests, and end-to-end tests
- Selective testing: When not all tests run on every commit, tags allow Qlty to carry forward coverage information for different components
How Tags Affect User Experience
When you use coverage tags in your project:
- Each tag reported for a pull request receives its own coverage gate (total coverage and/or diff coverage)
- Individual tag results appear in separate sections in PR comments
- On the pull request coverage tab, changes can be filtered by one or more tags
- When browsing coverage for your default branch, the coverage presented combines coverage across all tags
Implementing Coverage Tags
To use coverage tags, simply add the --tag
option to the qlty coverage publish
command when publishing different parts of your coverage:
Tags with Report Merging
Coverage tags work seamlessly with report merging, allowing complex workflows while maintaining tag-specific insights.
Important Considerations
When using coverage tags with report merging:
- Each
qlty coverage publish
command applies to a single tag (or no tag) - Merging always refers to combining reports for the same tag, not across different tags
- Server-side merging requires tracking completion separately for each tag
Client-Side Merging with Tags
With client-side merging, run the qlty coverage publish
command once per tag, combining all reports for that tag:
Server-Side Merging with Tags
For server-side merging, each tag must be handled independently.
Using total-parts-count
with tags
When using the total-parts-count
approach, specify the count separately for each tag:
Using coverage complete
with tags
When using the --incomplete
flag approach, upload parts for each tag and then send a completion signal for that specific tag:
Common Use Cases for Tags
Multi-Language Projects
In projects with multiple programming languages, each with their own test frameworks:
Monorepo with Multiple Components
For monorepos with distinct components that each need tracking:
Different Test Types
When separating coverage by test type:
Tag Management
Tags Persistence
Because Qlty supports selective testing with tags, tags “live forever” once created. This ensures that coverage information for each tag can be tracked and reported consistently over time, even when tests for certain tags aren’t run on every commit.
Deleting Tags
If you need to remove a tag that’s no longer being used:
- Navigate to your project in Qlty Cloud
- Go to Project Settings → Code Coverage
- Find the tag in the list of coverage tags
- Click the “Delete” button next to the tag name
Note that deleting a tag will remove all historical coverage data associated with that tag, so use this option with caution.
Troubleshooting
Tag Reporting Issues
If you’re experiencing issues with tagged coverage reports:
- Verify that the tag name is consistent across all commands
- Ensure you’re providing the correct tag when using
coverage complete
commands - Check that the tag name doesn’t contain special characters or spaces
Missing Tag Data
If coverage data for a specific tag isn’t appearing:
- Confirm that the coverage report was successfully uploaded
- Verify that the correct tag was specified in the upload command
- For reports using server-side merging, check that the completion signal was sent
- Ensure all parts of a tagged report have been uploaded if using the
total-parts-count
approach
See Also
- Coverage Merging - How to merge multiple coverage reports
- CI Integration - Automate coverage reporting in CI
- Path Fixing - Fix path discrepancies in reports