Package testing: tinytest or meteortesting:mocha?

On one hand, Meteor uses tinytest for its own packages, and this is also the preconfigured way in the skeleton for a new package.

On the other hand, the Meteor Guide describes meteortesting:mocha as test driver for package testing.

IMHO, this is confusing, especially as you have to run meteor test-packages ./ --driver-package test-in-console for the preconfigured tests, which doesn’t seem to be described anywhere. Otherwise, I get lots of warnings because Blaze and JQuery are missing (the default driver-package is test-in-browser using Blaze).

My questions:

  1. What is the recommended way to write tests for the packages?
  2. Shall I update the guide or the skeleton for new packages to give a consistent view on this topic?

Maybe it would be sufficient to describe both ways in the Meteor Guide, but at least it should contain a clear recommendation to make it easier for new package authors.

1 Like

That’s a good point. On the one hand Tinytest is easy to learn has no external dependencies but more complex tasks, like coverage or headless testing for ci are quite a pain, at least to me.

My current stack is meteortesting:mocha together with npm chai and sinon and puppeteer for headless testing.

It requires some setup (so I would recommend it for intermediate users) but it works stable that we use it for all projects.

I also support to cover both technologies and I would favor to have a distinct description why users should choose which one for which kind of use-cases.

I also miss some more detailed docs for tinytest or did I just searched at the wrong spots?

This is the only documentation that I’ve found: meteor/packages/tinytest at devel · meteor/meteor · GitHub

The package is missing on https://docs.meteor.com/ Maybe it would be a good start to describe it at least here, together with the accompanying packages test-in-browser, test-in-console, test-server-tests-in-console-once (even two of them are marked as internal Meteor packages).

Tinytest is currently used only for testing packages (at least in the meteor repo). Would it also work on application level? The skeletons for meteor create use meteortesting:mocha.

Same here with the only exception being cypress used for our Frontend E2E testing.

tinytest is more suited for small scale stuff where you want to assert certain results but even then jest/expect is a lot more powerful. Keep in mind, many of the tooling used in Meteor was in a time where the JS ecosystem was way less developed as it’s today.

I believe as Meteor converts more of its packages to NPM, tinytest is going to be deprecated.

So, use meteortesting:mocha along with your own choice of libraries like sinon, chai, expect or cypress as @jkuester and @a4xrbj1 suggested.