I am generating coverage reports using nyc
in Node 16.
However, for some reason, the coverage report (both lcov and html) is messed up, because the paths to the source files are wrong. They follow the pattern:
<relative path>file:<absolute path><file name>
e.g. SF:src/rest/file:/home/<user>/code/<project>/src/rest/auth.ts
in lcov.info
Consequently, my html coverage reports show errors like
Unable to lookup source: /home/<user>/code/<project>/src/rest/file:/home/<user>/code/<project>/src/rest/auth.ts (ENOENT: no such file or directory, open ...
for all files.
I found out, that the sourcemaps have paths starting with "file:///".
Also, in the "coverage" folder, there are obscure folders named "file:", which seem to resemble the absolute path with folders inside.
I can't figure out why this is, but I want the reports to use relative paths to my project directory.
I found the reason: there recently was a patch update of ts-node
from 10.8.0 to 10.8.1 - where they switched to File URIs in the source maps.
A downgrade to 10.8.0 solved the problem for me.
Regarding the bug/compatibility issue with nyc, there's an ongoing discussion in ts-node's repo: https://github.com/TypeStrong/ts-node/issues/1790