-
Notifications
You must be signed in to change notification settings - Fork 79
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
Option for excluding mappings #51
Comments
I suspect the I think what you are saying is that while you get one big bundle of original coverage, that breaks out into a load of other files when remapped, of which you are only interested in the subset, and because of your build pipeline and tooling, it isn't easy to not collect the coverage information in the first place. |
Yes your assumptions are right.. I found a working solution for me:
var istanbul = require('istanbul');
var collector = new istanbul.Collector();
var reporter = new istanbul.Reporter();
var remappedJson = require('./../generated/coverage-remapped.json');
var keys = Object.keys(remappedJson);
var coverage = {};
for (var i = 0; i < keys.length; i++) {
if (keys[ i ].startsWith('src/')) {
coverage[ keys[ i ] ] = remappedJson[ keys[ i ] ];
}
}
collector.add(coverage);
reporter.add('html');
reporter.write(collector, true, function() {}); |
@otbe thanks for your solution, I added it to my project karma-sourcemap-writer. And it lets karma + webpack + babel work. +1 for this feature! |
Hi
let me explain what Im doing at the moment. I have a quite large electron app written in typescript. The only way to run tests for me in electron as a karma "browser" (at moment of writing) is to bundle all tests files. Im using webpack for this. This works great so far. Now I want to add coverage statistics to my test setup and
remap-istanbul
comes over the rainbow. Great tool so far. 👍Passing the json output of
karma-coverage
toremap-istanbul
produces the following html output:The only entry thats interesting is
src/utils/
. The json generated bykarma-coverage
contains only one entry and this is my generated test bundle.What I want to do is:
remap-istanbul --exclude-mapping=~/,tests/,webpack,__root__/
The generated html would only contain one entry for
src/utils/
Is there a way to archive this?
Thank you :)
Another thought on this:
The generated json by
remap-istanbul
contains all files listed in the picture above. Can I execute a reporter based on this json? So it would be possible to "clean" the json from undesired files.The text was updated successfully, but these errors were encountered: