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.

This can then be further processed from the internal format into well known formats by the deno coverage tool.

  1. # Go into your project's working directory
  2. git clone https://github.com/oakserver/oak && cd oak
  3. # Collect your coverage profile with deno test --coverage=<output_directory>
  4. deno test --coverage=cov_profile
  5. # From this you can get a pretty printed diff of uncovered lines
  6. deno coverage cov_profile
  7. # Or generate an lcov report
  8. deno coverage cov_profile --lcov > cov_profile.lcov
  9. # Which can then be further processed by tools like genhtml
  10. genhtml -o cov_profile/html cov_profile.lcov

By default, deno coverage will exclude any files matching the regular expression test\.(js|mjs|ts|jsx|tsx) and only consider including specifiers matching the regular expression ^file: - ie. remote files will be excluded from coverage report.

These filters can be overridden using the --exclude and --include flags. A module specifier must match the includeregular expression and _not match the exclude_ expression for it to be a part of the report.