I really need some code coverage tools and the existing packages I’ve found for Meteor aren’t working with Meteor 1.6
It seems like the rest of the Node world is using nyc to instrument tests.
It works like magic but is kind of a hack imho and meteor breaks the hacks that it uses. It is possible to get it working by specifying a path directly to the meteor tool index.js like so:
meteor npx nyc meteor node $HOME/.meteor/packages/meteor-tool/1.6.0-beta.13/mt-os.osx.x86_64/tools/index.js test --once --settings test.json --full-app --driver-package meteortesting:mocha
Another thing experiment I did today was using the istanbul babel plugin to get coverage output on the server side with some short patches to
meteortesting:mocha. I’ll publish this in a fork shortly if anyone is interested in checking it out, but it has minimal configuration options currently.
What’s missing? One thing is the ability to have different babel environments in .babelrc since you wouldn’t want to run istanbul babel plugin in production.
Also I didn’t manage to get it working for client tests yet but it shouldn’t be too hard.
There’s really two situations where coverage would be nice:
For CI I’d like to output coverage reports and upload to coveralls/codecov. the NYC method of running Meteor test is actually a good way to go here, I think what would be required is a reliable way to invoke meteor that works with nyc that doesn’t break the magic meteor does either. I may take a stab at this later and try to understand how Meteor could work with the nyc shim.
Interactive coverage reports: this is where I want to add more tests to improve my coverage. What’s important here is the console output and HTML coverage generation from
meteortesting:mocha. Getting it working for both client and server tests is ideal.
Anyway, I will continue on and let you know what I figure out.