istanbuljs / nyc

the Istanbul command line interface
https://istanbul.js.org/
ISC License
5.59k stars 359 forks source link

Question: NYC Code Coverage Path Mapping for Shared Libraries #1573

Open Harcsa95 opened 3 months ago

Harcsa95 commented 3 months ago

I'm currently working on a project that includes two applications, appA and appB, and a shared-library where I store common code between these two applications. The directory structure of the shared library is as follows: app/shared-library/src/my/library

When I generate code coverage for the shared library from appA, the source file paths in the coverage report are prefixed with .nyc_output/sources/resources/, like so: SF:.nyc_output/sources/resources/my/library/components/ComponentA.js However, when generating coverage for appA, the paths are not prefixed, I have appA, in which I have webapp folder, which contains my ui code, and the coverage path is the following: SF:webapp/components/ComponentB.js

This inconsistency in path prefixes makes it difficult to aggregate and compare coverage reports across the applications and the shared library.

I'm looking for a way to pass a parameter to NYC to map or alias the path .nyc_output/sources/resources/my/library/components to shared-library/src/my/library in the coverage report. This would make the paths consistent and easier to work with.

Is there a current feature that supports this? If not, could this be considered for a future enhancement? Thank you.