I'm using the meteor-coverage package (version 1.1.4) with mocha (version 2.4.5_6) and meteor version 1.4.4.1 on Ubuntu 14.04 LTS. I have been able to produce very pretty test coverage reports, but it seems that for the client-side tests something is amiss. In order to send the coverage data to localhost:3000/coverage I have created a function called sendCoverage()
which I import in my .tests.js files:
export const sendCoverage = function sendCoverage() {
Meteor.sendCoverage(function(stats,err) {console.log(stats,err);});
};
I call this function after a block of mocha tests:
after (function () {
sendCoverage();
});
Now, this produces test coverage reports in my localhost:3000/coverage page, but it seems as though it does not display the coverage properly. For example, I see that some statements are executed, but are highlighted in red and flagged as not covered. For example:
It seems as though the statements get executed 11 and 12 times, respectively. However, they are not flagged as being covered and in my reports the percentage of statement coverage reflects this.
Does anyone know what I may be doing wrong and/or have experience with client-side code coverage and the meteor-coverage package?
Thanks!
Post-solution edit
It seems I've got it working now. The percentages on Codacy match the percentages in my html report. Looking at the html report more closely, it seems the coverage numbers were correct after all. It was simply the drill down that was showing odd behavior. So, the conclusion is that it worked after all, but it took Codacy's second opinion to confirm this to me. My new approach will be to create lcov coverage reports with spacejam (see Ser's answer below) and export these to an external service like Codacy, Codecov or SonarQube.
Thanks Serut for the input!