nyc icon indicating copy to clipboard operation
nyc copied to clipboard

nyc instrument doesn't work at all

Open ericmorand opened this issue 4 years ago • 1 comments

Link to bug demonstration repository

Consider the following project:

https://gitlab.com/eric.morand/nyc-instrument

{
  "all": true,
  "include": [
    "src"
  ],
  "reporter": [
    "text"
  ]
}

Execute:

nyc instrument test dist

Expected Behavior

The instrumented code is present in the dist directory.

Observed Behavior

There is no dist directory.

Observations

It looks like nyc instrument ignores the test directory because it is not present in the include directive. It doesn't make sense: the include directive serves as declaring the sources that needs coverage, not the sources that can be instrumented.

When checking coverage, we want to run a test suite and then compare the list of hit source files against the list of source files that we want to cover - namely the include directive. And obviously we want to instrument this test suite and its whole dependency graph even though we don't want the test suite itself to be part of the final comparison - we only want what is in the include directive to be compared with the hit files.

Am I missing something or is nyc fundamentaly flawed?

ericmorand avatar Sep 09 '21 11:09 ericmorand

+1 trying to look at the source code to figure this out! Try the ./test ./dist ? also not working ....

adligo avatar Apr 26 '23 05:04 adligo