The deno coverage command generates code coverage reports from coverage profiles collected during test runs.
Usage
deno coverage [OPTIONS] [FILES]...
Description
Print coverage reports from coverage profiles. Coverage profiles are generated by running deno test with the --coverage flag.
Flags
Ignore coverage files matching these patterns. Can be specified multiple times
Include source files matching these patterns in the report. Can be specified multiple times
Exclude source files matching these patterns from the report. Can be specified multiple times
Output coverage report in LCOV format
Output coverage report in HTML format
Output detailed coverage report showing line-by-line coverage
Write coverage report to specified file or directory. For HTML output, this should be a directory
Coverage Report Types
Summary (default)
Shows overall coverage statistics:
Detailed
Shows line-by-line coverage for each file:
deno coverage --detailed coverage/
LCOV
Generates an LCOV format report (compatible with many coverage tools):
deno coverage --lcov coverage/ > coverage.lcov
HTML
Generates an HTML coverage report:
deno coverage --html --output=html_cov coverage/
Examples
Generate coverage during tests
First, collect coverage data:
deno test --coverage=coverage/
View coverage summary
Generate detailed coverage report
deno coverage --detailed coverage/
Include specific files
Only show coverage for files matching a pattern:
deno coverage --include="src/" coverage/
Exclude files from report
Exclude test files from the coverage report:
deno coverage --exclude="test" coverage/
Generate LCOV output
deno coverage --lcov --output=coverage.lcov coverage/
Generate HTML report
deno coverage --html --output=html_cov coverage/
Filter with multiple patterns
deno coverage --include="src/" --exclude="src/vendor/" coverage/
Integration with CI/CD
GitHub Actions example
- name: Run tests with coverage
run: deno test --coverage=coverage/
- name: Generate coverage report
run: deno coverage --lcov --output=coverage.lcov coverage/
- name: Upload to Codecov
uses: codecov/codecov-action@v3
with:
files: ./coverage.lcov