Skip to content

test_runner: add initial code coverage support

Rodrigo Muino Tomonari requested to merge github/fork/cjihrig/coverage into main

This commit adds code coverage functionality to the node:test module. When node:test is used in conjunction with the new --test-coverage CLI flag, a coverage report is created when the test runner finishes. The coverage summary is forwarded to any test runner reporters so that the display can be customized as desired. This new functionality is compatible with the existing NODE_V8_COVERAGE environment variable as well.

There are still several limitations, which will be addressed in subsequent pull requests:

  • Coverage is only reported for a single process. It is possible to merge coverage reports together. Once this is done, the --test flag will be supported as well.
  • Source maps are not currently supported.
  • Excluding specific files or directories from the coverage report is not currently supported. Node core modules and node_modules/ are excluded though.

Merge request reports

Loading