Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The --cwd option breaks instrumentation on Windows #1310

Open
3 tasks
elliot-nelson opened this issue May 14, 2020 · 6 comments
Open
3 tasks

The --cwd option breaks instrumentation on Windows #1310

elliot-nelson opened this issue May 14, 2020 · 6 comments

Comments

@elliot-nelson
Copy link

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 [email protected] (--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
@elliot-nelson
Copy link
Author

Note: I did see #1234, but the solution to that report doesn't seem to have fixed this problem. (The problem occurs even without any nycrc file, without adding any other flags like report-dir, etc.)

@addaleax
Copy link
Member

@elliot-nelson This is istanbuljs/test-exclude#43, potentially being fixed by istanbuljs/test-exclude#44

@elliot-nelson
Copy link
Author

@addaleax It seems related but I wonder if this will fix my situation where there are no uppercase files? I'm willing to test it out later today though, it looks like I could copy the fix into my local node modules.

@addaleax
Copy link
Member

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

@ryancabanas
Copy link

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 [email protected] 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 [email protected], 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!

@AEsmerio
Copy link

AEsmerio commented Nov 9, 2021

@ryancabanas , you've solved my issue.
I've [email protected] working on my Mac, but it wasn’t working on Windows.
Downgrading [email protected] works fine for both.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants