new·The score now tells you which way it movedA brain's exam only ever grows: its own material writes questions, and so does every question a real caller asked and did not get answered. The score is a percentage over that growing set, so a brain that learned more could post a smaller number — and this week three did. One of them answered two MORE questions than the week before and showed eighteen points less. Printed as a single percentage, that reads as decline to a reader and as punishment to anyone who contributes material.all news →
mozg.beta
Sign in

Deno · Reference · all subjects

cli commands/coverage

23 notes, read out of this brain and free to use. Each one was extracted from a source and is re-checked against its exam.

export coverage to lcov format example

To export test coverage from the default coverage profile to an lcov file: run deno test --coverage to collect data, then run deno coverage --lcov --output=cov.lcov to generate the lcov file.

deno coverage command overview

The deno coverage command generates coverage reports from data collected by deno test --coverage. It processes coverage data to produce reports in various formats.

coverage default inclusions and exclusions

By default, deno coverage includes any code that exists on the local file system and its imports. Files containing test.js, test.ts, test.jsx, or test.tsx in their name are excluded by default. This is equivalent to using --exclude="test\.(js|mjs|ts|jsx|tsx)$".

coverage --include flag

The --include option customizes coverage inclusions with a regex pattern. It can also expand coverage to include files not on the local file system. Example: deno coverage --include="^file:|https:" includes both local and remote files.

coverage --exclude flag

The --exclude option customizes which files are excluded from the coverage report using a regex pattern. For a URL to match, it must match the include pattern and not match the exclude pattern.

deno-coverage-ignore-file directive

Add a // deno-coverage-ignore-file comment at the top of a file to ignore the entire file from the coverage report. Ignored files will not appear in the coverage report.

deno-coverage-ignore directive for single lines

Add a // deno-coverage-ignore comment on the line above code to ignore that single line from the coverage report.

deno-coverage-ignore-start and deno-coverage-ignore-stop directives

Add a // deno-coverage-ignore-start comment above code and a // deno-coverage-ignore-stop comment below to ignore multiple lines. Each start comment must be terminated by a stop comment, and ignored ranges may not be nested. Invalid comments will produce warnings.

coverage ignore comment format requirements

Only white space may precede a coverage directive in a coverage comment, but any text may trail the directive. Coverage comments must start with // (block comments starting with /* are not valid). Example: // deno-coverage-ignore Trailing text is allowed.

function coverage metric

Function coverage measures the percentage of declared functions that were called at least once during the test run. It appears as a function coverage column alongside branch and line columns in the summary table and HTML report. The same data is available in lcov output.

coverage --threshold flag

Pass --threshold to deno coverage with a whole-number percentage to set a minimum coverage threshold. The value applies to all three metrics: line, branch, and function coverage. The command exits with non-zero code when coverage falls below the threshold. Example: deno coverage --threshold=90

deno test --coverage-threshold flag

When collecting and checking coverage in a single step, pass --coverage-threshold to deno test. Example: deno test --coverage --coverage-threshold=90

deno.json coverage thresholds configuration

Set per-metric coverage thresholds in deno.json under a coverage section with a thresholds object. Each key (lines, branches, functions) is optional and accepts a fractional percentage. Example: {"coverage": {"thresholds": {"lines": 90, "branches": 80, "functions": 90}}}. A metric with no configured threshold is not checked.

coverage threshold precedence

When the --threshold CLI flag is passed, its single value applies to line, branch, and function coverage and overrides whatever deno.json sets for each metric. With no flag, the per-metric deno.json values are used.

coverage --lcov flag

The --lcov flag outputs the coverage report in lcov format, a standard file format for code coverage data. Example: deno coverage --lcov --output=cov.lcov

coverage --output flag

The --output flag specifies the filename for the coverage report output. Example: deno coverage --lcov --output=cov.lcov outputs to cov.lcov.

coverage --html flag

The --html flag outputs the coverage report as an HTML file. Example: deno coverage --html

DENO_COVERAGE_DIR environment variable

The DENO_COVERAGE_DIR environment variable can be used to set the coverage directory for deno test. Example: DENO_COVERAGE_DIR=custom_profile_name deno test, then deno coverage custom_profile_name

coverage profile naming with --coverage flag

When running deno test --coverage=custom_profile_name, a custom coverage profile is created. This profile can then be passed to deno coverage: deno coverage custom_profile_name

basic coverage report generation workflow

To generate a coverage report from the default coverage profile: run deno test --coverage to collect data, then run deno coverage to generate the report.

coverage report with include pattern example

To only include coverage matching a specific pattern, use the --include flag with a regex. Example: deno coverage --include="main.ts" includes only coverage from main.ts

deno coverage command

deno coverage is used to generate test coverage reports.

deno coverage --lcov flag generates LCOV coverage reports

The `deno coverage --lcov cov/` command generates a coverage report from collected coverage data and stores it as an .lcov file. This format integrates well with services such as Codecov, Coveralls, and Travis CI.

Give your agent this brain