-
Notifications
You must be signed in to change notification settings - Fork 787
getting istanbul cover
to show 0% coverage for files with no tests
#112
Comments
Sorry, somehow this issue fell through the cracks. Yes, that is expected behavior. You could work around this issue by requir-ing all files in your codebase using some generic code in a test case. Let me know if you still want to re-open this issue. |
This one confused me a lot too. It doesn't seem like the coverage report is much use if its leaving out files that are untested. The purpose of the report, at least for my use case, is to see where code is and isn't covered to inform tasks to go and cover a section of code that isn't being covered. I would expect my instrumented code to include all of the code I want reported, and the report to show me a line item for each instrumented file and their corresponding coverage - showing 0% coverage for files with 0 coverage. This is a great tool but unfortunately i'll have to find something else because of this issue. |
Maybe what you're looking for is the includeUntested option. I set that to true and get a full report for all of my files. |
@domrein where did you find the |
@morficus you can find it in help, |
Having the same issue any help !! my karma.config `module.exports = function(config) {
}; Does any other coverage reporter works better than istanbul? It is important for us to get coverage of non tested files. |
@shaikhspear16 Don't know what you mean that it doesn't work? What are you trying to achieve? have you tried the code below?
|
I know this thread is old (and closed), but I wanted to add another possible solution for the benefit of people arriving here via google. Using
You can see this in action here (hacky but working): https://github.com/tstibbs/os-map/blob/50b6ae026a261927d1d9cbd0f4fa88252c6ec014/package.json#L6 |
…d to pass the srcGlob anywhere in the karma config in terms of files or preProcessors to get the coverage report. It is the case that the coverage report only shows files that have some testing in them - here is the gitHub issue to that regard gotwarlost/istanbul#112
where should the |
@ORESoftware The I use mocha, es6 and want to run all coverage inside my Here's what I use: |
Set up istanbul-instrumenter-loader for use with TypeScript and webpack. |
easy way to get 0% coverage. add following function to core.js in istanbul middleware. function createNonTestedFilesCoverage(opts){ call above function in post method in handler.js in istanbul-middleware folder. and finally provide "staticdir: your path//public-coverage" inside coverage.createHandler function in express file. run express file and run your test cases and you will get all 0% coverage in your report. |
I have taken few changes from gulp-istanbul and solved the above issue by modifying code in istanbul-middleware. Please go through the below link: http://litutech.blogspot.in/2017/09/adding-0-coverage-in-istanbul-code.html |
Was only reporting the files that had unit tests. Had to include the --include-all-sources flag, and set the directory to test using --root. See gotwarlost/istanbul#112
So does it mean that Istanbul don't work at all with ES Modules that use import instead of require? I have 0% after refactored into ES modules. |
I really think the istanbul maintainers should reopen this issue. If I have one file tested with 100% coverage in a project of 10 files, the other 9 files should at least report 0%, giving me a combined total of 10% coverage. But it gives me 100% instead 😳 . I realize Istanbul needs the files to actually be imported somewhere to know they exist. So is there some way we could specify the files we'd like coverage for that will be automatically added to the overall coverage percentage (even if they don't have tests)? @gotwarlost already made a great suggestion in #112 (comment) on how to work around this issue
It's what I've been doing for my projects. But why couldn't this workaround be implemented into istanbul? |
Hi,
I was very reluctant to open this issue -- it's more of a question really -- but I cannot find an answer to it anywhere. And it seems such a basic thing that I'm sure I'm just missing something in here...
If I have a node project with a couple of .js files. And I have created a single test file which tests a couple of functions from one file only.
The test is a jasmine test, inside
test
directory, which is run by doingjasmine test
. I get my 2 tests, 2 assertions, all ok.Now I want to get coverage data for my code.
I do
istanbul cover jasmine-node -- test
and I get coverage results only for the .js file I tested, i.e., I'm getting 83% coverage when in fact there's one file in there that's not even being tested.So, am I doing this wrong or do I have the wrong expectation here?
Is there a way to get
istanbul cover
to give me results which reflect also the files which weren't tested?Many thanks,
L.
The text was updated successfully, but these errors were encountered: