[SOLVED] `meteor test-packages` doesn't run tinytests on server?

ANSWER: Both client and server test results are displayed in the browser, unlike Mocha, where server tests show up in the server spew (which is what I was expecting). Nothing to see here.

// package.js
Package.onTest(function(api) {
  api.use([
    'tinytest',
    'mongo',
    'my-package']);
  
  // Using A, B, *or* C below -- no luck running my test on the server

  // A
  api.addFiles('my-package-tests.js');
  
  // B
  api.addFiles('my-package-tests.js', ['client', 'server']);
  
  // C
  api.mainModule('my-package-tests.js', 'client')
  api.mainModule('my-package-tests.js', 'server')
});
// my-package-tests.js
if (Meteor.isServer) console.log('SERVER')
else if (Meteor.isClient) console.log('CLIENT')

Tinytest.add("simple", function (test) {
  test.equal(1, 1);
})

I’m running using

meteor test-packages ./packages/my-package --port 25111 --release 3.0.4

The simple test runs on the client, in a browser, but on the server, no tests are run. SERVER does indeed print, but again, no tests run.

Do I need to adjust my command or package.js? What gives?

Thanks!

Bump. Anyone have any experience running server tests for packages?

Did you try meteor test-packages my-package?

No luck

➜  meteor test-packages my-package --port 25111 --release 3.0.4                                                                                                                     <<<
=> Errors while collecting tests:

While trying to test package `my-package`:
error: Not a known local package, cannot test

Hmm that’s interesting. What is the full name of the package in package.js?

Here’s what works for me:

  1. I put the package in the /packages folder
  2. Grab the package name from the package.js file, e.g.
Package.describe({
  name: 'jam:method',
  ...
  1. Run meteor test-packages jam:method --release 3.0.4

Hey, so actually I was indeed using the wrong package name when I would specify it directly.

However, I’m now specifying the package name exactly as it is in package.js and I get the same output.

I’ve got a super simple test file, which is being processed, but the test does not run.

const meteorVersion = Meteor.release ? parseFloat(Meteor.release.split('@')[1]) : null;

if (Meteor.isServer) console.log('SERVER')
else if (Meteor.isClient) console.log('CLIENT')

console.log(meteorVersion)

Tinytest.add("simple", function (test) {
  console.log('SIMPLE TEST REACHED')
  test.equal('fail', 'bar');
})

This prints:

SERVER
3

and that’s it

:_ )

Again, my command:

meteor test-packages my-actual-package-name --port 25111 --release 3.0.4

My package.js looks like this:

Package.describe({
  name: "my-actual-package-name",
  summary: "Foo",
  version: "1.0.0",
  documentation: "README.md",
  git: "https://github.com/foo/my-actual-package-name.git",
});

Package.onUse(function(api) {
  api.versionsFrom(['1.12.1', '2.3', '3.0']);
  api.use(['mongo']);

  api.addFiles('my-package.js');
});

Package.onTest(function(api) {
  api.use([
    'tinytest',
    'mongo',
    'my-actual-package-name']);

  api.mainModule('collection-helpers_tests.js', 'client')
  api.mainModule('collection-helpers_tests.js', 'server')
});

See anything off here?

Thanks so much for your help.

Do you see any errors on the client when running the tests? I’ve sometimes seen this happen, and if I remember correctly it’s been because there was an error on the client.

OK, hold up here. LOL, do both client & server results load in the browser? I expected server results to print to the console, like mocha. :sweat_smile: :sweat_drops:

Oh dear, yes, I see that’s what the “S:” and “C:” are for, and this explains the duplicates. Nothing to see here. Thanks.