Integrate Code Coverage Formats

Qlty accepts coverage data in multiple formats compatible with various tools and languages. If your specific format is not supported, you can easily convert your code coverage report to the qlty format to ensure smooth integration.

See Supported Languages and Formats for more information.

Qlty Format

Qlty supports the import of a generic format, named qlty, which can be used as a target for custom conversion of reports from tools that are not directly supported.

This means you can convert the report file produced by your code coverage tool into the qlty format and then upload the converted report.

Specification

The qlty format follows the JSON Lines text file format, also called newline-delimited JSON. Each line contains one JSON object.

The structure of each JSON object is described using the JSON schema standard, a declarative language that provides a standardized way to describe JSON data.

1{
2 "$schema": "https://json-schema.org/draft/2020-12/schema",
3 "title": "File Line Coverage",
4 "description": "Indicates which lines of a file have been covered",
5 "type": "object",
6 "properties": {
7 "path": {
8 "description": "The file's path to inform code coverage for",
9 "type": "string"
10 },
11 "hits": {
12 "description": "Sepcifies the number of times each line of the file has been covered",
13 "type": "array",
14 "items": {
15 "description": "The number of hits for a specific line in the file, where -1 indicates the line was excluded from the report or it's irrelevant, and non-negative integers indicate the number of hits",
16 "type": "string",
17 "pattern": "^(-1|[0-9]+)$",
18 }
19 }
20 }
21}

Following, an example of a consolidated qlty report:

{ path: "user.js", hits: ["-1", "-1", "0", "0", "1", "4", "1", "2", "0", "-1"] }
{ path: "todo.js", hits: ["3", "3", "3", "0", "-1", "-1", "1", "2", "0", "4", "4", "4", "4"] }
{ path: "item.js", hits: ["0", "0", "0", "0", "0", "-1", "0", "0", "0", "0", "0", "0", "0"] }
{ path: "account.js", hits: ["1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1"] }

JSON Lines files are generally saved with the .jsonl extension, so it’s recommended to save your qlty formatted coverage report with this extension.

The path Property

Ideally, the file path for your code coverage report should be relative to your Git project’s root. However, you can transform the path using the universal reporter tool with the --strip-prefix and --add-prefix flags, modifying the final path of the uploaded report.

The hits Property

Depending on the tool used to exercise your code base, a single line could be:

  • Irrelevant regarding code coverage (e.g., comments) (“-1”)
  • Not covered (“0”)
  • Covered, possibly multiple times.

This structure ensures that you can translate and submit coverage reports in a consistent format, regardless of the tool used to generate them.

Uploading a qlty formatted Coverage Report

Uploading a qlty formatted coverage report is no different than uploading a code coverage report in any other format. Follow these steps:

  1. Convert your report to the qlty format.

  2. Get your Qlty coverage token from your project’s settings page under the Code Coverage section.

  3. Upload the report using Qlty’s coverage reporter:

1export QLTY_COVERAGE_TOKEN=your_token
2./qlty coverage publish path/to/coverage_report.jsonl

For explicitness, you can use the --format=qlty flag to specify the format, though qlty will infer it by default:

1./qlty coverage publish --format=qlty path/to/coverage_report.jsonl

Need help?

If you need support for a specific code coverage format, contact our support team. We may be able to complete the process within one week.