nyc does not work with symlinks
See original GitHub issueI reproduced the issue in this repo: https://github.com/aalexgabi/nyc-symlink-problem/commit/3ce1fe85f2f8bb723a2ede92bf1d9a324655c8e2 When I don’t use a symlink it does work: https://github.com/aalexgabi/nyc-symlink-problem/commit/9da9355e8111233e8efa38f85aef9de2f6fd713c
This was reported many times (not sure all issues here are due to symlinks) but not fixed:
- https://github.com/istanbuljs/nyc/issues/962
- https://github.com/istanbuljs/nyc/issues/472
- https://github.com/istanbuljs/nyc/issues/741
- https://github.com/istanbuljs/nyc/issues/833
Expected Behavior
I should have symlinked files from node_modules included:
running
working
ran
-----------------------|---------|----------|---------|---------|-------------------
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
-----------------------|---------|----------|---------|---------|-------------------
All files | 100 | 100 | 100 | 100 |
src | 100 | 100 | 100 | 100 |
test.js | 100 | 100 | 100 | 100 |
src/node_modules/work | 100 | 100 | 100 | 100 |
index.js | 100 | 100 | 100 | 100 |
-----------------------|---------|----------|---------|---------|-------------------
Observed Behavior
I don’t have symlinked files from node_modules included:
running
working
ran
----------|---------|----------|---------|---------|-------------------
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
----------|---------|----------|---------|---------|-------------------
All files | 100 | 100 | 100 | 100 |
test.js | 100 | 100 | 100 | 100 |
----------|---------|----------|---------|---------|-------------------
Troubleshooting steps
- still occurring when I put
cache: false
in my nyc config
Environment Information
% npx envinfo@latest --preset nyc
npx: installed 1 in 0.741s
System:
OS: Linux 5.5 Manjaro Linux
CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
Memory: 887.34 MB / 15.52 GB
Binaries:
Node: 13.7.0 - ~/.fnm/current/bin/node
Yarn: 1.22.0 - /usr/bin/yarn
npm: 6.13.6 - ~/.fnm/current/bin/npm
npmPackages:
nyc: ^15.0.1 => 15.0.1
Issue Analytics
- State:
- Created 3 years ago
- Reactions:2
- Comments:9 (4 by maintainers)
Top Results From Across the Web
The Complete Guide to Creating Symbolic Links (aka ...
You can create symbolic links using the mklink command in a Command Prompt window as Administrator. To open one, locate the “Command Prompt” ......
Read more >Creating a symlink directory on a network share to a path ...
#File Not Found UNC paths don't work: 1) navigate to a network share: pushd \\windows2008server\share\ 2) make a symlink:
Read more >Symbolic link - Wikipedia
In computing, a symbolic link (also symlink or soft link) is a file whose purpose is to point to a file or directory...
Read more >If circular symlinks are useless, then why are they allowed?
They seem to say conclusively that there is no reason one would ever create such a circular symlink, and therefore it must have...
Read more >How to Create Symbolic Links: A Comprehensive Guide
What Does a Symbolic Link Do? A symbolic link points to the original file on your system but doesn't contain data in the...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Coverage of files outside the project isn’t supported. It might work for you to tweak your settings as follows:
The
cwd
says that the project root is the directory aboveprocess.cwd()
, theinclude
options are modified to be relative to the explicitly setcwd
. Note that unlike other options thecwd
option has slightly different meaning when provided to CLI vs when provided in config. If you rannyc --cwd ..
then this would prevent nyc from findingproject/.nycrc
. Thus you have to put thecwd
option intoproject/.nycrc
.@coreyfarrell thanks for the
cwd
suggestion - it worked like a charm! Now I can test coverage across multiple packages in my monorepo (a yarn workspace):Think it would be worth documenting this for people using monorepos