Skip to content

Proposal: provide a straight-forward approach for collecting coverage via Chrome's Profiler #16531

@bcoe

Description

@bcoe

The Problem

I've been having an ongoing discussion with @bmeck and a few folks working on the V8 project (@schuay, @fhinkel) about how to move istanbul towards using v8's built-in coverage.

The biggest blocker, tracked in the v8 issue tracker here, is that we need a way to start Node with detailed coverage enabled. -- @schuay can speak better to the specifics, but as I understand it code needs to be put through a preprocessing step that introduces counters, currently we're only able to collect function-level coverage.

There are a few other blockers that I will also outline in this issue.

Collecting Detailed Coverage

  • @schuay proposes introducing a v8 flag that could be passed to Node when starting, and would run inspector with detailed reporting enabled; does this mean that we'd need to stat Node.js with --inspector or could we still enable this post-hoc?

Other Challenges

There are a few other technical challenges that will need to be addressed, to make the switch over to v8's test coverage:

  • if an application exits using process.exit or by throwing an exception, it's hard to capture this event and output the coverage information (since talking to the inspector's socket is asynchronous); One option might be using spawnSync within process.exit(), but this currently has bugs.
  • v8's coverage output is significantly different than Itanbul's coverage.json format we'll need to write something that translates between the formats.

Why this is super cool

  • transpilation to add coverage counters is complex and error-prone, it would be neat to have this happen at the v8 level.
  • code transpiled for test coverage runs significantly slower than the code prior to transpilation; I'm betting collecting coverage directly from v8 will be fast (although the subprocess shenanigans might add some overhead).
  • this would give us a way to collect coverage for .mjs module files, which is currently not possible since the new module system does not execute require.extensions.

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature requestIssues that request new features to be added to Node.js.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions