-
Notifications
You must be signed in to change notification settings - Fork 82
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
Reported coverage only increases and never decreases without terminating gulp #40
Comments
I just got really weird failures when editing my instrumented code. After restarting gulp and not changing the code it is working again. It seems that my code is instrumented multiple times. Maybe that is a hint... |
You probably shouldn't rerun the instrumentation on each watch event triggers if you're running everything in the same process. |
Good idea! However, this did not fix it. Weird. I never got this issue before in other configurations. (I just verified it again.)
Do you have any other idea? (I am diving into the internals now.) |
I found the cause. :)
My current workaround is to provide my own gulp.task('test-crawler', ['clean-coverage'], function (done) {
var coverageVariable = '$$cov_' + new Date().getTime() + '$$';
gulp.src([
paths.crawler.jsFiles,
paths.common.jsFiles
])
.pipe(istanbul({
coverageVariable: coverageVariable
}))
.on('finish', function () {
gulp.src([
paths.crawler.specFiles
])
.pipe(mocha())
.on('error', function () {
console.log(chalk.bold.bgRed(' TESTS FAILED '));
done();
})
.pipe(istanbul.writeReports({
reporters: ['lcov'],
coverageVariable: coverageVariable
}))
.on('end', done);
});
}); @SBoudrias It would be great if you could find a nicer solution that you can bake into gulp-instanbul. I guess many people fall into this trap. (Hopefully they notice and not just think their coverage is higher than it actually is.) My current workaround also has the disadvantage that the global namespace is polluted when my watch task is running for a long time. (My RAM would be big enough but it would be nice to know that this - you could call it memory leak - is fixed.) |
Thanks for digging the bug. I'll see what I can do about it. Creating a new var for each run would be a good first step. I'm just unsure about deleting it as this plugin don't know when the user is done with the instrumented code. |
Mmh, good point. As I understand you baked into gulp-instanbul the ability to run multiple test runs (e.g. one for unit tests in the browser, one for the server libs, and one for end to end tests in the browser) and finally do a report that sums up the coverage of all test runs? That is powerful! +1 I would say there are two groups of users:
Maybe there is a solution that allows the first group not having to do anything and the second group e.g. passes additional options. The second group is certainly more advanced and can be burdened with the task to get the options right. (Namely setting So I guess it is indeed a good starting point to create a new Just my 5 cents. The more I think about it the more I realize how tricky it is. ;) |
I wrote several unit tests and get the coverage report (html) as expected. I have a watch task and therefore execute the unit tests again and again. When I add another test the reported coverage goes up as expected. However, when I comment out a test the reported coverage does not go down again. For an accurate coverage report I have to terminate gulp and start my watch task again.
My otherwise good working code is:
Did I configure something wrong? Or what else might be the cause?
The text was updated successfully, but these errors were encountered: