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

nyc on Windows shows 0 coverage #1381

Open
1 task done
osher opened this issue Jan 14, 2021 · 16 comments
Open
1 task done

nyc on Windows shows 0 coverage #1381

osher opened this issue Jan 14, 2021 · 16 comments

Comments

@osher
Copy link

osher commented Jan 14, 2021

Link to bug demonstration repository

https://github.com/mariszin/nyc-coverage-0-sample

(Taken from #1076...)

Expected Behavior

After tests, nyc should show 100% coverage

Observed Behavior

When running tests on Windows, the coverage is 0. Not even after upgrading to nyc@15

C:\ws\nyc-coverage-0-sample>nyc mocha


  HelloWorld
    √ should return hello world with no arguments
    √ should return passed argument


  2 passing (6ms)

---------------|----------|----------|----------|----------|-------------------|
File           |  % Stmts | % Branch |  % Funcs |  % Lines | Uncovered Line #s |
---------------|----------|----------|----------|----------|-------------------|
All files      |        0 |        0 |        0 |        0 |                   |
 helloWorld.js |        0 |        0 |        0 |        0 |         1,2,3,5,9 |
---------------|----------|----------|----------|----------|-------------------|


C:\ws\nyc-coverage-0-sample>npm ls nyc
[email protected] C:\nyc-coverage-0-sample
`-- [email protected]


C:\ws\nyc-coverage-0-sample>npm i nyc@15 --save-dev
npm WARN [email protected] No description                                                                                                                                          bel\helper-module-transforms-1c5a7680 (356ms)
npm WARN [email protected] No repository field.

+ [email protected]
added 65 packages from 26 contributors, removed 29 packages and updated 25 packages in 11.652s

25 packages are looking for funding
  run `npm fund` for details


C:\ws\nyc-coverage-0-sample>nyc mocha


  HelloWorld
    √ should return hello world with no arguments
    √ should return passed argument


  2 passing (7ms)

---------------|---------|----------|---------|---------|-------------------
File           | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
---------------|---------|----------|---------|---------|-------------------
All files      |       0 |        0 |       0 |       0 |
 helloWorld.js |       0 |        0 |       0 |       0 | 1-9
---------------|---------|----------|---------|---------|-------------------

Troubleshooting steps

  • still occurring when I put cache: false in my nyc config

Environment Information

C:\ws\nyc-coverage-0-sample>npx envinfo@latest --preset nyc
'npx' is not recognized as an internal or external command,
operable program or batch file.

C:\ws\nyc-coverage-0-sample>npm i -g envinfo
C:\Program Files (x86)\Nodist\bin\envinfo -> C:\Program Files (x86)\Nodist\bin\node_modules\envinfo\dist\cli.js                                                                       node_modules\.staging
+ [email protected]
added 1 package from 1 contributor in 0.862s

C:\ws\nyc-coverage-0-sample>envinfo --preset nyc

  System:
    OS: Windows 10 10.0.19041
    CPU: (8) x64 Intel(R) Core(TM) i7-8550U CPU @ 1.80GHz
    Memory: 2.95 GB / 15.85 GB
  Binaries:
    Node: 12.18.4 - C:\Program Files (x86)\Nodist\bin\node.EXE
    npm: 6.14.6 - C:\Program Files (x86)\Nodist\bin\npm.EXE
  npmPackages:
    nyc: ^15.1.0 => 15.1.0

@osher
Copy link
Author

osher commented Jan 17, 2021

yea, I know it's frustrating, I saw how the other issue fell in the abyss.
but I would like to help with that - and I'm ready for a lot:

  • we can exchange quicker correspondences in a personal channel
  • we can setup a google-meet/zoom and share screen if that will help
  • I can also do the PR and pass your CI f you'll only point me in the right direction and save me time of getting in to this so I understand what I'm looking for

Osher

@osher
Copy link
Author

osher commented Jan 31, 2021

I'm still standing, yea yea yea...

@osher
Copy link
Author

osher commented Feb 11, 2021

Oh, aaai - I'm still alive, yeeoo

@PhakornKiong
Copy link

I was not able to reproduce the error by cloning and running it on my own machine.

I've tried both v14 and v15, it is working as intended.

nyc mocha



  HelloWorld
    √ should return hello world with no arguments
    √ should return passed argument


  2 passing (15ms)

---------------|---------|----------|---------|---------|-------------------
File           | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
---------------|---------|----------|---------|---------|-------------------
All files      |     100 |      100 |     100 |     100 |
 helloWorld.js |     100 |      100 |     100 |     100 |
---------------|---------|----------|---------|---------|-------------------
  System:
    OS: Windows 10 10.0.21286
    CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
    Memory: 5.58 GB / 15.86 GB
  Binaries:
    Node: 15.0.1 - E:\CodeProgram\Node\node.EXE
    npm: 7.5.2 - E:\CodeProgram\Node\npm.CMD
  npmPackages:
    nyc: ^14.0.0 => 14.0.0 

@osher
Copy link
Author

osher commented Feb 18, 2021

WTF. I also just cloned a project where it worked on windows.
It tried on v15.1, v15.1 and v14 and they all worked, the culprit is not there.

I'll find the differences and update, but will be able to do it next week.

@osher
Copy link
Author

osher commented Feb 22, 2021

bullseye! 🎯
I manage to find a reproduction scenario. @Darkripper214 - lets hope it's the only one.

First - disclaimer

when I posted the issue I edited out parts from the paths because I did not think it makes a difference.
But evidently, it did, because one of the edited out path folders was a symlink (junction).

I use a symlink because the ops guys destroyed my name when creating my ldap username. By the time I got to open a ticket to fix that - they could fix everything except for the original underlying LDAP username - and sadly, that happens a lot with my consultation customers.
So I hide it with a symlink, and since I did not want my name in the bug description - I edited it out.

Anyway - see for yourself:

reproduction scenario

C:\git clone https://github.com/mariszin/nyc-coverage-0-sample 
//... bla bla bla...
C:\cd nyc-coverage-0-sample
C:\nyc-coverage-0-sample>npm i
// ... bla bla bla ...
C:\nyc-coverage-0-sample>nyc mocha

  HelloWorld
    √ should return hello world with no arguments
    √ should return passed argument


  2 passing (14ms)

---------------|---------|----------|---------|---------|-------------------
File           | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
---------------|---------|----------|---------|---------|-------------------
All files      |     100 |      100 |     100 |     100 |
 helloWorld.js |     100 |      100 |     100 |     100 |
---------------|---------|----------|---------|---------|-------------------

C:\nyc-coverage-0-sample>cd ..
C:\>mklink /J nyc-coverage-0-sample-symlink nyc-coverage-0-sample
Junction created for nyc-coverage-0-sample-symlink <<===>> nyc-coverage-0-sample
C:\>cd nyc-coverage-0-sample-symlink
C:\nyc-coverage-0-sample-symlink>nyc mocha


  HelloWorld
    √ should return hello world with no arguments
    √ should return passed argument


  2 passing (14ms)

---------------|---------|----------|---------|---------|-------------------
File           | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
---------------|---------|----------|---------|---------|-------------------
All files      |       0 |        0 |       0 |       0 |
 helloWorld.js |       0 |        0 |       0 |       0 | 1-9
---------------|---------|----------|---------|---------|-------------------

C:\nyc-coverage-0-sample-symlink>

This leads me to suspect that when symlinks are involved nyc may be watching the wrong paths

@osher
Copy link
Author

osher commented Feb 22, 2021

@Darkripper214 - whats the procedure here, should I update the bug description above to make it easier for future readers that land on the issue from something they googled?
I mean, is that something you do here, or you prefer to preserve the narrative?

@osher
Copy link
Author

osher commented Feb 22, 2021

ha. I've got it.

follow up here: istanbuljs/test-exclude#46

@osher
Copy link
Author

osher commented Feb 22, 2021

actually, we may not need to wait for the PR on test-exclude if we pass it from nyc side a path already resolved through fs.realpath.
LMK what you think.

@osher
Copy link
Author

osher commented Mar 16, 2021

@Darkripper214 - sup?

@osher
Copy link
Author

osher commented Mar 30, 2021

Summary: I found the culprit, it's in test-exclude.
We can wait for them, or we can pass them an already resolved path.
@Darkripper214 - what do you think?|

@osher
Copy link
Author

osher commented Mar 30, 2021

omg. sorry for the noise. I thought I was getting maintainers in the autocomplete when I type"@".

@coreyfarrell, you look a frequent committer on both projects - are you a maintainer of this project? Can we have your opinion?

@osher
Copy link
Author

osher commented May 18, 2021

so. what's the move?

@GerHobbelt
Copy link

Same problem here. This time, SUBST-based. See istanbuljs/test-exclude#46 (comment)

GerHobbelt added a commit to GerHobbelt/markdown-it-footnote that referenced this issue Jul 3, 2021
updated build environment
fixed some bother, filed mochajs/mocha#4675
noted istanbuljs/nyc#1381 but no dice
@osher
Copy link
Author

osher commented Sep 19, 2021

any decision?

@andyleejordan
Copy link

I hope that nyc gets fixed for Windows and updated, I'd like to use it, but right now it's not usable on Windows at all.

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