The --cwd option breaks instrumentation on Windows
See original GitHub issueLink to bug demonstration repository
https://github.com/elliot-nelson/nyc-bug-demo
Expected Behavior
Running nyc --cwd spec jasmine should instrument the specs run, and produce a coverage report:
1 spec, 0 failures
Finished in 0.023 seconds
Randomized with seed 40333 (jasmine --random=true --seed=40333)
---------------|---------|----------|---------|---------|-------------------
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
---------------|---------|----------|---------|---------|-------------------
All files | 100 | 100 | 100 | 100 |
index-spec.js | 100 | 100 | 100 | 100 |
---------------|---------|----------|---------|---------|-------------------
Observed Behavior
Adding the --cwd option removes all instrumentation:
1 spec, 0 failures
Finished in 0.017 seconds
Randomized with seed 50629 (jasmine --random=true --seed=50629)
----------|---------|----------|---------|---------|-------------------
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
----------|---------|----------|---------|---------|-------------------
All files | 0 | 0 | 0 | 0 |
----------|---------|----------|---------|---------|-------------------
Troubleshooting steps
- Issue occurs only on Windows (the --cwd flag works as expected on MacOS/Linux)
- Issue does not occur in Windows using nyc@14.1.1 (–cwd flag works as expected)
- Suspecting the issue is with jasmine, I tried modifying the the
"spec_dir"setting inspec/support/jasmine.json- this didn’t work (jasmine is running the right files, those files just aren’t instrumented).
Environment Information
npx: installed 1 in 1.869s
System:
OS: Windows Server 2012 6.3.9600
CPU: (2) x64 Intel(R) Xeon(R) CPU E5-2686 v4 @ 2.30GHz
Memory: 5.63 GB / 8.00 GB
Binaries:
Node: 8.15.0 - c:\nodejs\node.EXE
npm: 6.4.1 - c:\nodejs\npm.CMD
npmPackages:
nyc: ^15.0.1 => 15.0.1
Issue Analytics
- State:
- Created 3 years ago
- Reactions:2
- Comments:6 (2 by maintainers)
Top Results From Across the Web
Breaking Out of Citrix and other Restricted Desktop ...
For our purposes, setting this to something like “C:\windows\system32\cmd.exe” could be useful. This has now effectively turned Command Prompt ...
Read more >Examining landowners' preferences for a chronic wasting ...
In this study, we used a discrete choice experiment to assess landowners' preferences for a proposed CWD management response in southeastern ...
Read more >Command-line API | Node.js v19.3.0 Documentation
Activate inspector on host:port and break at start of user script. ... This option is only supported on macOS and Windows.
Read more >Erlang -- erl
The erl program on Windows provides no line editing in its shell, and on Windows 95 there is no way ... Option i...
Read more >PySimpleGUI
You can override this setting at the Window and Button levels. ... You're JUST getting started, so cut yourself a break and use...
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 Free
Top 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

I’m new to programming, so I know my statements could be completely off, but I am experiencing an issue using the
cwdoption too, like @elliot-nelson.I was using
nyc@15.1.0in my NodeJS project and I had placed thenycpackage in a location other than my project’s root folder. When I attempted to use thecwdoption to specify the project’s root folder, I got the same empty coverage report like @elliot-nelson showed. I only got valid results if I actually moved thenycpackage to my project’s root folder.If I downgraded to
nyc@14.1.1, as @elliot-nelson mentioned, I began getting a valid coverage report even with thenycpackage in a folder other than the project’s root folder and using thecwdoption to specify the project’s root folder.I’m not sure if this is helpful at all to this particular thread, but I thought I would mention it, as the content here did help me to find out that I wasn’t going crazy after and I was actually using the
cwdoption correctly after all. 😃 Thanks!@elliot-nelson I think it’s also about the comment I just left on the fix about using
path.resolve()instead ofpath.join()😃