Is meteortesting:mocha the recommended Mocha testing package? With code coverage?

I’m currently using meteortesting:mocha package when I run my Mocha tests.

As the code coverage isn’t supported anymore by this package automatically, I’m wondering if the Meteor community is now suggesting a different package that includes code coverage?

Also, I think I saw that there’s a new package that is updated to Meteor 3.x and ticks of all the boxes.

meteortesting:mocha was last updated in Jan 2023.

Thanks in advance!

1 Like

As the code coverage isn’t supported anymore by this package automatically, I’m wondering if the Meteor community is now suggesting a different package that includes code coverage?

I remember serut/meteor-coverage working fine in Meteor 2.x. Was it not effective for you? I’ve had positive experiences with it in past projects. Or do you refer with the 3.x support?

Regarding Mocha tests, last time I checked, meteortesting:mocha worked well with Meteor 3.x. Doesn’t it for you? Unsure about its code coverage support, might need adjustments for async code.

I’ve been tackling tasks in the Meteor community on the past, ensuring test functionality works at minimum. Yet, going into code coverage with meteortesting:mocha remains pending, as it has had less priority than common tests execution.

I’m not testing Meteor 3.x - I will wait as I have no time for testing beta or RC versions.

I was wondering if Grubba (I think he worked on meteortesting:mocha) could add a code coverage to the package again as he is working on the 3.x update?

Or someone else?

I haven’t worked with serut/meteor-coverage in the past, only with the package that was then taken out of meteortesting:mocha.

That package still has code coverage solution described on its description, GitHub - Meteor-Community-Packages/meteor-mocha: A Mocha test driver package for Meteor 1.3+. This package reports server AND client test results in the server console and can be used for running tests on a CI server or locally.

That package is actually serut/meteor-coverage, which I worked with it on the past as well, using Meteor 2.x. Do you have any troubles with that implementation? As it worked for projects I worked on, I believe it will work for yours.

FWIW here’s a script that I used successfully 2 years ago but stopped using since it only worked on the custom darwin-arm64 build of nodejs 14 and not on the standard x64 build that our build servers run.

It runs tests using mocha but wrapped in nyc coverage. The script source code is probably from a forum post here.

#!/usr/bin/env bash
export TZ=UTC
export BABEL_ENV=meteor:coverage

NODE=`meteor node -e "process.stdout.write(process.execPath)"`
METEORJS=`meteor node -e "process.stdout.write(require('path').resolve(process.execPath, '../../../tools/index.js'))"`
node_modules/.bin/nyc --reporter=lcov --reporter=text-summary \
  $NODE $METEORJS $* test TEST_CLIENT=0 \
  --raw-logs --once --driver-package meteortesting:mocha  --exclude-archs web.browser.legacy