question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

The --cwd option breaks instrumentation on Windows

See original GitHub issue

Link 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 in spec/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:open
  • Created 3 years ago
  • Reactions:2
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
ryancabanascommented, Aug 5, 2021

I’m new to programming, so I know my statements could be completely off, but I am experiencing an issue using the cwd option too, like @elliot-nelson.

I was using nyc@15.1.0 in my NodeJS project and I had placed the nyc package in a location other than my project’s root folder. When I attempted to use the cwd option 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 the nyc package 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 the nyc package in a folder other than the project’s root folder and using the cwd option 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 cwd option correctly after all. 😃 Thanks!

1reaction
addaleaxcommented, Oct 19, 2020

@elliot-nelson I think it’s also about the comment I just left on the fix about using path.resolve() instead of path.join() 😃

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found