You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Cannot get coverage report if c8 is running in a sub-directory & src is one level up. #527
Hello! When I have c8 running from a sub-directory, I can't seem to get it to report coverage for src code that is one level up from where c8 is running.
Yes. Actually, c8 doesn't consider the location of the configuration file as the base path to resolve the sources to cover. This makes declaring the sources there useless except when executing c8 from the same directory as the one where the configuration file is located.
There are some other issues too that prevent c8 from working properly outside of the "root" directory: include and exclude are also not relative to the configuration file location, and they basically contradict the src configuration and the source map of the executed module. Basically c8 is plagued by the same design decisions as nyc but to an even greater extent.
@cenfun thank you..I think you got it right by having both a source and an entry filter approach. Can you elaborate a bit on entryFilter?
Typically:
We can use entryFilter to filter the entry files. For example, we should remove vendor.js and something-else.js if they are not in our coverage scope.
Since we have to execute a command (i.e. interpreting an entry point with node like doing npm t), we have an entry point. In what context would we want to filter it out?
@ericmorand Both can generate coverage reports from raw v8 coverage data. c8 uses the converter v8-to-istanbul, and it can only generate Istanbul reports. mcr uses its own converter (can analyze AST). In addition to generating Istanbul reports, it can also generate V8-style reports.
Activity
ericmorand commentedon May 7, 2024
I have the same issue: #498
cenfun commentedon May 8, 2024
For
sub-directory, the source fileindex.jsis outside of the current working directory, so it was excluded. see https://github.com/istanbuljs/test-exclude/blob/master/index.js#L90-L92ericmorand commentedon May 8, 2024
Yes. Actually, c8 doesn't consider the location of the configuration file as the base path to resolve the sources to cover. This makes declaring the sources there useless except when executing c8 from the same directory as the one where the configuration file is located.
There are some other issues too that prevent c8 from working properly outside of the "root" directory: include and exclude are also not relative to the configuration file location, and they basically contradict the
srcconfiguration and the source map of the executed module. Basically c8 is plagued by the same design decisions asnycbut to an even greater extent.cenfun commentedon May 9, 2024
@ericmorand You can try mcr CLI
skullpsg commentedon May 9, 2024
@timganter Can you try with --allowExternal on the cmd. It would work.
ericmorand commentedon May 9, 2024
@cenfun thank you..I think you got it right by having both a source and an entry filter approach. Can you elaborate a bit on
entryFilter?Typically:
Since we have to execute a command (i.e. interpreting an entry point with node like doing
npm t), we have an entry point. In what context would we want to filter it out?cenfun commentedon May 9, 2024
@ericmorand Both can generate coverage reports from raw v8 coverage data.
c8uses the converterv8-to-istanbul, and it can only generate Istanbul reports.mcruses its own converter (can analyze AST). In addition to generating Istanbul reports, it can also generate V8-style reports.ericmorand commentedon May 9, 2024
I opened an issue in your repository to move the conversation there: cenfun/monocart-coverage-reports#22
timganter commentedon May 13, 2024
@skullpsg sorry, no 🎲 . You can try it out on my repo here: https://github.com/timganter/c8-sub-directory?tab=readme-ov-file#steps-to-reproduce