NYC output is empty with mocha installed globally
See original GitHub issueExtracted from #822 I experience no coverage output when both nyc and mocha installed globally (in fact, only mocha installation plays role). Reproducible repo is here Env: Windows 7 Node 10.15.1 Nyc 13.3.0 Mocha 6.0.2
D:\Projects\nyc-test>nyc mocha
√ should have tests
1 passing (39ms)
----------|----------|----------|----------|----------|-------------------|
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s |
----------|----------|----------|----------|----------|-------------------|
All files | 0 | 0 | 0 | 0 | |
----------|----------|----------|----------|----------|-------------------|
D:\Projects\nyc-test>npm i mocha
(...) skipped
D:\Projects\nyc-test>nyc node_modules\.bin\mocha
√ should have tests
1 passing (39ms)
----------|----------|----------|----------|----------|-------------------|
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s |
----------|----------|----------|----------|----------|-------------------|
All files | 100 | 100 | 100 | 100 | |
stub.js | 100 | 100 | 100 | 100 | |
----------|----------|----------|----------|----------|-------------------|
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:27 (7 by maintainers)
Top Results From Across the Web
node.js - No coverage nyc mocha - Stack Overflow
I have installed mocha globally and when nyc referring mocha globally it does't show anything in the coverage report.
Read more >mochajs/mocha - Gitter
Hey, I'm using JSDOM to build up an empty window for my mocha tests, and I'm running into a JSDOM error for which...
Read more >Mocha documentation — DevDocs
Installation. Install with npm globally: $ npm install --global mocha. or as a development dependency for your project: $ npm install --save-dev mocha....
Read more >Unit testing in Node.js - IBM Developer
Next, you'll install each of the test packages. Install Mocha. From the terminal window, enter this command: npm i --save-dev mocha. The output...
Read more >Nyc And Mocha Code Coverage Failing When Running In ...
With Istanbul installed, prepend your existing Mocha command with the NYC binary. ... NYC output is empty · Issue #822 · istanbuljs/nyc ·...
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

Same issue , While Running

nyc mochaBut while Running
nyc node_modules/.bin/mocha``
After maaaany hours of debugging I finally found the problem. It’s the
cmdandshellfiles and spawn-wrap.They check if the node executable is in the same directory as they are, when they are installed as modules they work because there’s no node executable there and it then relies on using the one in the PATH, but it’s there when installed globally.
That’s not a problem on Unix because it uses a symbolic link to the JS file. Unless you use a Windows installation on Unix, then you have the same bug.
My solution right now is to patch
spawn-wrapwith this:It’s a very dirty solution honestly but haven’t put much effort.