dbt-coverage
raw JSON → 0.4.1 verified Mon Apr 27 auth: no python
One-stop-shop for docs and test coverage of dbt projects. v0.4.1 supports dbt up to 1.9, with commands to measure column documentation, test, and model coverage, and compare coverage reports. Frequent patch releases.
pip install dbt-coverage Common errors
error ModuleNotFoundError: No module named 'dbt_coverage' ↓
cause dbt-coverage not installed in the current Python environment.
fix
pip install dbt-coverage
error KeyError: 'nodes' ↓
cause The manifest JSON file is missing the 'nodes' key, likely an old dbt or incorrect file path.
fix
Ensure you run
dbt docs generate and point to the correct manifest.json (e.g., target/manifest.json). Warnings
breaking v0.4.0 changed how test hits are counted (feat!(test): count number of hits). Existing workflows expecting the old test counting may see different totals. ↓
fix Review test coverage numbers after upgrade; adjust thresholds if needed.
gotcha manifest and catalog must be compiled before running CoverageReport. Running from a fresh dbt project without `dbt docs generate` will cause errors. ↓
fix Run `dbt docs generate` or `dbt compile` and `dbt docs generate` before using dbt-coverage.
gotcha When using model aliases, the coverage nodes may be incorrectly matched. Fixed in v0.3.3, but still possible with unconventional alias usage. ↓
fix Upgrade to >=0.3.3.
Imports
- CoverageReport wrong
from dbt_coverage.report import CoverageReportcorrectfrom dbt_coverage import CoverageReport - get_coverage_report wrong
from dbt_coverage import get_coverage_reportcorrectfrom dbt_coverage import CoverageReport
Quickstart
from dbt_coverage import CoverageReport
import json
# Point to a dbt project with compiled manifest and catalog
report = CoverageReport(
manifest_json='target/manifest.json',
catalog_json='target/catalog.json'
)
result = report.report()
print(json.dumps(result, indent=2))