-
-
Notifications
You must be signed in to change notification settings - Fork 73
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
Coverage for untested files? #105
Comments
@ZebraFlesh do you use
|
@marco-ramirez have any advice for @ZebraFlesh? |
@bcoe Nope, I'm using karma. |
@ZebraFlesh I think you'll need to do something similar to nyc: https://github.com/istanbuljs/nyc/blob/master/index.js#L235 or, @marco-ramirez's gulp plugin: In which you walk all files, and collect the coverage report -- if you find a good approach for Karma, I'd love to add it to the istanbul website. @marco-ramirez, likewise, it would be good to add a tutorial with your gulp example to the website. |
I am also having a similar issue with this project here: https://github.com/psachs21/web-boilerplate I run the coverage but it only reports on coverage of the tested files, not the untested files. I am using ava with nyc. Any ideas? |
@ZebraFlesh have you tried the karma-coverage plugin? It uses istanbul and seems to have an option to include all source files in the coverage reports. |
I had not seen that, thank you! I'm a bit over whelmed at the moment, so will try it in a day or two. |
@marco-ramirez my example repo does everything @bcoe mentioned, it still does not work. It is using |
So I gave that includeAllSources options on the karma-coverage plugin a try, but didn't have any luck. It seems that option has been present in the plugin for a while, but has been unreliable. So I'm back to square one on how to pass an |
I think I've figured out how to cover all files from a karma perspective, but I'm not using the Am I missing something? Is Previously, my karma
For simple cases, I changed it to the following:
For more complex cases, it's possible to filter the webpack dynamic context:
|
@ZebraFlesh any follow up work you can think of from this issue? it sounds like you did eventually get karma instrumenting all files? Could we add documentation on the istanbul website? could updates be made to karma or Istanbul to make things easier? |
Correct, I did eventually get karma to instrument all of the files through istanbul. Propagating the "simple case" documentation I outlined above would probably be helpful. I'm not sure if there's anything beyond that to be done for either karma or istanbul -- there's no simple solution to the problem, so you can't just solve it with a flag. Expounding a bit: when you run your tests, they're going to inherently pull in just their dependencies. (In this context, I'm using "dependency" to describe an ES6 module import tree.) For example, I have Ultimately software projects are messy, but karma has the necessary hooks to deal with it and make things work with istanbul. It was just a bit of work to put the pieces together. |
For those, who use Karma + Istanbul – take a look on this plugin https://github.com/kopach/karma-sabarivka-reporter. Configuration is simple like that: reporters: [
// ...
'sabarivka'
// ...
],
coverageReporter: {
include: 'src/**/!(*.spec|*.module|environment*).ts',
exclude: 'src/main.ts',
// ...
}, It works, as already mentioned above – by scanning your project files and adding them to coverage report. |
How do I use the coverage for untested files feature introduced in the 4.1.0 release? I reviewed the PR and it looks like I have to specify an
onCover
function, however, I'm currently specifying my istanbul config via a.babelrc
file:This has treated me very well so far, but it seems incompatible with the final version of this feature? (The originally proposed version seemed much more amenable, but alas was cut.) I'm running tests via karma, so have a karma config available if that helps.
The text was updated successfully, but these errors were encountered: