Skip to content

Commit

Permalink
docs: Add --clean flag to coverage docs (#614)
Browse files Browse the repository at this point in the history
  • Loading branch information
byvide authored Jul 24, 2024
1 parent 994ff9a commit 6bd0691
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions runtime/manual/basics/testing/coverage.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@ title: "Test Coverage"
---

Deno will collect test coverage into a directory for your code if you specify
the `--coverage` flag when starting `deno test`.

This coverage information is acquired directly from the JavaScript engine (V8)
which is very accurate.
the `--coverage` flag when starting `deno test`. This coverage information is
acquired directly from the JavaScript engine (V8), ensuring high accuracy.

This can then be further processed from the internal format into well known
formats by the `deno coverage` tool.
Expand All @@ -15,13 +13,26 @@ formats by the `deno coverage` tool.
> immediately after running tests. Otherwise source code and collected coverage
> data might get out of sync and unexpectedly show uncovered lines.
The `--clean` flag has been introduced to the test runner
[with Deno v1.44](https://deno.com/blog/v1.44#clean-coverage-directory-on-test-runs).
This flag empties the coverage directory before running the test suite,
preventing outdated coverage data from long-deleted files from lingering.
However, be aware that this flag will cause conflicts when running multiple
`deno test` commands in parallel or in series, and then viewing the aggregated
coverage report. If you are running tests in parallel, you should not use this
flag. If running in series, only pass this flag to the first `deno test`
invocation.

```bash
# Go into your project's working directory
git clone https://github.com/oakserver/oak && cd oak

# Collect your coverage profile with deno test --coverage=<output_directory>
deno test --coverage=cov_profile

# Use the --clean flag if you need to ensure old coverage data is cleared
deno test --coverage=cov_profile --clean

# From this you can get a pretty printed diff of uncovered lines
deno coverage cov_profile

Expand Down

0 comments on commit 6bd0691

Please sign in to comment.