-
Notifications
You must be signed in to change notification settings - Fork 12k
feat (CodeCoverage): use karma-remap-istanbul #1468
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
Conversation
use karma-remap-istanbul to map code coverage back to source typescript file
@Brocco I am seeing the CI builds have been running for like 20 min. I don't believe I would have done anything here to cause this? |
use karma-remap-istanbul to map code coverage back to source typescript file (+1 squashed commit) Squashed commits: [b444648] remove trailing comma feat (CodeCoverage): use karma-remap-istanbul use karma-remap-istanbul to map code coverage back to source typescript file
…ular-cli into karma-remap-istanbul
Heya! Sometimes the builds just take a while. In travis some show has having errored though. I'm not too sure of the purpose of this PR though, can you tell me what's the issue you're trying to solve? |
Sure! So currently. The code coverage report displays the compiled js files and not the source ts files. This should fix that |
Ok I understand it now. Yeap, that needs fixing, thank you for taking it up. Me and @TheLarkInn should be reviewing when the CI is stable, since we worked on the current implementation. |
👍 |
As a maintainer (sure?) of I've had issues with the plugin, but don't know enough about karma plugins to be considered a maintainer. If someone would like to take a look at it, by all means, please do. There are two PRs on the repo that use @devCrossNet was working on a fix that created a task that used Edit: Relevant PR - #895 |
@delasteve Hello, it's me ... ;-) I could update my coverage branch to keep my implementation up to date with the new webpack stuff. But I am still waiting for the remap-istanbul release. Or should I stop working on this feature? |
I had a short look at the new implementation. the test process changed and there is some new kind of karma plugin. I need some time to dive into the Code and get everything working again. |
The new karma plugin was added to have the whole build process for tests managed via karma. I made it but I wouldn't say I'm very knowledgeable of karma plugins, it's just editing the config really. |
@deebloo tests seem to be failing a lot with this PR, I can restart the build but the instability seems due the the changes introduced in here. |
@@ -22,10 +23,34 @@ module.exports = function (config) { | |||
{ pattern: './src/test.ts', watched: false } | |||
], | |||
preprocessors: { | |||
'./src/**/**/*.ts': ['angular-cli-coverage'], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would you be willing to explain this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added a new preprocessor in the karma plugin. While there is a single entry point for the tests in order to get the remap plugin to generate the mapped coverage report it needs to run over the test files themselves.
@filipesilva I understand that code. It is not much,I had trouble with the source maps and the processing of code coverage. But I tried it just a few minutes. I'll come back to you when I can't get it working again after a few hours. |
@filipesilva I am running my local tests again to see if I can spot what is wrong. Also, based on the conversation here do we want to try NOT using the remap karma plugin? |
cc @bryanforbes do you think you could lend your coverage and instrumentation expertise. Id love to make coverage as accurate as possible and you've worked on this extensively also. |
@deebloo I can't say one way or the other since I don't fully understand the question that is being brought up, but I have a considerable amount of respect for @delasteve and @devCrossNet since they put a lot of work into #895 (which I've closed when changing to webpack) so I'd like to understand what a better approach would be. |
@filipesilva fair. I will at least try to fix what I have so that this PR doesn't fail the tests, but after that I turn it over to the more experienced folks in the group |
update. so the tests just seem to hang the second time the e2e tests run the unit tests a second time. I can't find exactly why that is. It may be an issue with the karam plugin for remap. If that is the case (and based on other feed back in this feed). maybe I should just close this PR for now and let some of the other people who had been working on it take over. Thoughts? |
I evaluated the code yesterday and I think my approach is not going to work with the new webpack code (there are no files after the karma run, so I can not access the sourcemap files). I'll figure out another solution during the week. maybe the way would be a self-written, CLI optimized karma plugin-in. |
There are a couple of issues at play that should probably be addressed for more accurate code coverage:
I would be glad to submit PRs to both |
I merged in @bryanforbes's PR for |
I keep getting. |
@deebloo What version of the plugin? @delasteve just released |
@bryanforbes I am using 2.1. still getting that weird f error |
@bryanforbes I am getting this error now. Not sure if its my setup or the plugin. I can push my changes to the branch if you would like to see.
|
I believe you'll need to pass the {
test: /\.(js|ts)$/, loader: 'sourcemap-istanbul-instrumenter-loader',
exclude: [
/\.(e2e|spec)\.ts$/,
/node_modules/
],
query: { 'force-sourcemap': true }
} I'm in the process of trying to get a similar change made in |
# Conflicts: # addon/ng2/blueprints/ng2/files/config/karma.conf.js # addon/ng2/blueprints/ng2/files/package.json # addon/ng2/models/webpack-build-test.js # plugins/karma.js
should be working and passing all tests now. |
Thank you, @deebloo, @TheLarkInn, @bryanforbes, and @devCrossNet, for all the hard work you put into this. 👍 🎉 |
@deebloo would you be willing to add one or two tests in our e2e workflow that can test this feature. This will allow us to safeguard this featrue against future changes. Otherwise @filipesilva LGTM. |
@TheLarkInn Ill add one after all of the "test tests" run to make sure the correct folders exist |
@deebloo This might help you. It's from my PR when I was implementing this. |
reporters: [ | ||
{ type : 'json', subdir: '.', file: 'coverage-final.json'} | ||
] | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason to keep using karma-coverage
? karma-remap-istanbul
produces the coverage report and no longer needs the intermediate file and instrumenting is done by sourcemap-istanbul-instrumenter-loader
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you are correct. I misunderstood the docs for the karma plugin
Thank you everyone for your work. |
Just merged it in. A big thanks to @delasteve, @devCrossNet, @deebloo and @bryanforbes for making this work! It's been long in the backburner and the final solution is very elegant and clean imho. |
happy to help! you all are killing it with this newest update. (you know. in a good way). |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
use karma-remap-istanbul to map code coverage back to source typescript file