Unit testing for meteor packages

I am using meteor 1.9 + mongodb + react 16. meteor add meteortesting:mocha

The .test files in imports/ui… were run but my tests on packages were not recognized.

Do u know how can I run the tests on packages? The meteor documentation is not updated. They use practicalmeteor:mocha but it is deprecated now.

This is how I run:

TEST_BROWSER_DRIVER=chrome meteor test --once --driver-package meteortesting:mocha

Thanks!

but my tests on packages were not recognized

Your Meteor packages or NPM packages? For Meteor packages it’s actually the same command as in the documentation but instead with meteortesting:mocha.

Note, that you need to implement the packages tests in each package respectively.

Edit:

TEST_BROWSER_DRIVER=chrome meteor test-packages <package1path> <package2path> <packageNpath> --driver-package meteortesting:mocha

Thanks, when you say that I need to implement the packages tests in each package… you mean this?


// This defines the tests for the package:

Package.onTest((api) => {

  // Sets up a dependency on this package.

  api.use('webapps:handler');

  // Use the Mocha test framework.

  api.use('meteortesting:mocha');

  // Specify the source code for the package tests.

  api.addFiles('App.test.js');

});