Pat
Pat

Reputation: 5911

Package.on_test runs even when not testing

This is what our app looks like when starting:

=> Started proxy.
=> Started MongoDB.     
>>>>> IN ON_TEST
meteor-collection-management: updating npm dependencies -- mongodb...

Argh. In meteor-collection-management/package.js (our own package), there is this:

Package.on_test(function(api) {
    console.log(">>>>> IN ON_TEST");
    Npm.depends({
      mongodb: "1.4.1"
    });
    api.use(['meteor-collection-management', 'tinytest', 'test-helpers']);
    api.add_files('tests/dbobject-test.js', ['client', 'server']);
    api.add_files('tests/enums-test.js', ['client', 'server']);
});

Why is Package.on_test running? I am not running in test mode not even in node debug mode.

Upvotes: 0

Views: 67

Answers (1)

Tarang
Tarang

Reputation: 75945

The on test function just runs to build a dependency map, even though its not actually used. I see you've opened an issue on it too. Theres more info on what it does here: https://github.com/meteor/meteor/blob/a40a6273953c0e18eddcd67919754814461c5dd4/tools/packages.js#L1434

So it builds out .test, and needs to run the method to get the required files. Meteor needs to know what it needs before the project can run, which is probably why both run. (Package's need to be built into single files, as slightly different to the rest of Meteor)

Upvotes: 1

Related Questions