-
-
Notifications
You must be signed in to change notification settings - Fork 359
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 output is empty #822
Comments
This is because That explanation is an extreme paraphrase btw, there's a better one in the README and other places. |
@JaKXz I'm getting the same issue, here is the stub code (after trying to add a // test.js
const assert = require('assert');
const stub = require('./stub');
it('should have tests', () => assert.equal(stub, true)); // stub.js
module.exports = true;
|
Why are you setting |
@JaKXz My project which uses babel had that set already. Even in this simple test, turning it to |
Interesting. Try this tutorial: https://istanbul.js.org/docs/tutorials/es2015/ Coverage with babel should be no problem. |
I'm really confused by this because all I did to get your example repo working was remove |
So is that a bug in how nyc is processing the config file? |
@JaKXz ping |
|
Ok thanks. I have no work around yet. |
The problem is, Mocha is not exiting after its execution. So coverage report is unable to print as the execution is hold by mocha. |
I have not worked on that NYC since opening this issue, for those who still have their projects running, if @sibajeeray answer solves the issue, feel free to close it, else I will try something on it in the next couple of days. |
bro!!!!!!!, thanks a lot, i was worrying about how to end the mocha process after the tests has finished and how to display the coverage report. your solution solved my problems... thanks a lot once again |
I have the same issue, reproduced on macOS High Sierra using node v6.14.4 and v11.4.0. In an empty directory, install the deps.
Create this file it('one', function () {
return 'one'
})
it('two', function () {
return 'two'
}) Run mocha with nyc.
As you can see, the report is empty. Any ideas? |
@75lb I added a second file to your repro, I get coverage when I do that: lib.js: module.exports = { inc: x => x + 1 }; test.js: const { inc } = require('./lib');
it('1', () => inc('1')) Result:
Maybe nyc doesn't provide coverage inside the test files by default? |
OK, makes sense although I had the same empty results even when I tested separate files. I figured out my issue. I discovered a |
We should add to the troubleshooting steps to add Is everyone in this thread satisfied enough to close this issue? Perhaps a PR for 👆? :) |
I have a similar problem where I'm not able to view any tests in the coverage summary.
the flags I have specified are:
in the actual test script
and my output is
It looks like it's running all the tests using the node test script I provided and mocha is being invoked internally through the vscode 'testrunner', so I'm confused as to what's going on. Additionally, I do see files generated in the |
I currently experience the same issue as reported by @AnanyaJha Edit: I resolved my issue. I had a custom Before: ...
"babel": {
"env": {
"test": {
"plugins": [
"istanbul"
]
},
},
},
... After: ...
"babel": {
"env": {
"test": {
"plugins": [
"istanbul"
]
},
"jenkins": {
"plugins": [
"istanbul"
]
}
},
},
... |
The same issue. Reproduced with stub.js from this post and nyc installed globally. In my case issue seems to happen only with global mocha:
NB: Curiously, the presence of option "all" either in arguments or in
though coverage info still weird.
|
@Antonius-S were you able to get your setup working? |
@AnanyaJha kind of. I dislike the fact I need tons of mocha packages inside each of my tiny module's folder so I installed mocha from node's local folder ( |
Found one more workaround that doesn't use softlinks. Solution is for Windows and globally installed mocha, path to Node must be in Copy the text below and save as :: This batch launches globally installed mocha entry point
@ECHO OFF
SETLOCAL
SET NodeDir=
FOR /F %%S IN ('where node.exe') DO SET NodeDir=%%~dpS
IF NOT DEFINED NodeDir ECHO Node.exe not found in path && PAUSE && GOTO :EOF
node "%NodeDir%\node_modules\mocha\bin\mocha" %* |
there are a variety of reasons why coverage might be blank, and this thread seems to not be related to one specific cause. I'm closing this issue, but folks should feel free to open issues more specific to the problems they're bumping into; ideally with a minimal reproduction in a repo. |
@bcoe what do you think about my case (no coverage with global mocha but local mocha works OK)? Is it NYC issue or mocha's? Should I report it separately? |
@Antonius-S feel free to open an issue 👍 just want to make sure we're very specific about how to reproduce; these catch all issues almost never get solved, because there are multiple causes of empty coverage. |
maybe you can add 'cache-dir=your_cache_dir', so you can fix and get result quickly. |
Thank you. This worked like a charm. |
Hi had the same issue. mocha works correctly but nyc output and empty report.
|
@diiiego83 Having the same symptom does not mean you have the same issue (cause). Please post a new issue including all required information so we can troubleshoot your issue. |
I had this issue running in cmd however when I changed to using Ubuntu on WSL it worked a treat. So the process not exiting correctly appears to cause the issue with nyc not getting the reports |
Still facing this issue. I have tried all the above-mentioned solution. |
I have found if i test compiled code in |
My folder was called "test" so it skipped everything. Thank you. |
In case this helps any future travellers: our coverage broke when I declared a variable
|
Output is shown as empty.
Please help to fix this |
I have been trying for hours to find the problem here, but I can't, I tried many things, this is my test file (
unit-test.js
) insideprojectRoot/test
And this is my package.json:
when i run , the output shows coverage all 0% and no file name is mentioned, as shown below
The text was updated successfully, but these errors were encountered: