c8 icon indicating copy to clipboard operation
c8 copied to clipboard

Identify what test covers what lines

Open gaborbernat opened this issue 1 year ago • 1 comments

Currently, there's no way to find out what tests are covering a given line, it would be nice to have this feature. In the Python language this is named dynamic contexts, see https://coverage.readthedocs.io/en/7.4.3/contexts.html#dynamic-contexts.

gaborbernat avatar Mar 12 '24 17:03 gaborbernat

That would require a dedicated runtime to support this. c8 is just running whatever is passed as argument. There is no way for it to know how a line was hit if this information is not given by the runtime itself (node, or v8 more specifically).

Also, even if it was possible, how would it be able to detect the test? Basically: what is a test?

  • foo.mjs
export const foo = () => 5;
  • index.mjs
import {foo} from "./foo";

foo();
c8 node index.mjs

foo.mjs is fully covered here. But what would be the test?

ericmorand avatar Oct 26 '24 10:10 ericmorand