lukejagodzinski / meteor-astronomy-validators

https://atmospherejs.com/jagi/astronomy-validators
MIT License
11 stars 13 forks source link

Validators package not being included for test run builds #20

Closed rhomes-wcd closed 9 years ago

rhomes-wcd commented 9 years ago

When running Velocity or TinyTest test suites for a local package which uses the astronomy-validators package, the build file does not include the exported Validators object. As such a ReferenceError is thrown for the Astronomy classes that have validators defined for them.

If you need I also have a small test project setup where this issue can be reproduced, I can create a repo for your access if you need.

rhomes-wcd commented 9 years ago

Here is the test project if needed https://github.com/rhomes-wcd/validators-test

lukejagodzinski commented 9 years ago

It's not a problem with astronomy. You have to add:

api.imply('jagi:astronomy-validators');

in the Package.onUse.

Exports are only visible in the application. If you want to see exports in the package you have to use imply.

It's not well documented http://docs.meteor.com/#/full/pack_api_imply

rhomes-wcd commented 9 years ago

Thank you for the quick response, after reading more on imply and adding both use & imply to the package I am still seeing this error with the below changes. Please let me know if I am missing something...

Package.onUse(function (api) {
    api.versionsFrom('1.1.0.2');

    packages = [
        'mongo',
        'jagi:astronomy',
        'jagi:astronomy-validators'];

    api.use(packages);
    api.imply(packages);

    api.addFiles('lib/model.js', ['client', 'server']);

    api.export('testpackage', ['client', 'server']);
});

Package.onTest(function (api) {
    api.use('testproj:testpackage');
    api.imply('testproj:testpackage');

    api.use('sanjo:jasmine@0.15.5');

    api.addFiles('tests/jasmine/server/integration/server.js', 'server');
});
lukejagodzinski commented 9 years ago

Hmm strange. I will take a look at it in a few hours. I see that you've updated your repo so I will run it. However, after such changes in my test case it worked.

rhomes-wcd commented 9 years ago

Sounds great, I appreciate it.

lukejagodzinski commented 9 years ago

Sorry, I apparently was wrong. The imply method is not necessary. What you have to do is provide exact packages versions.

Package.describe({
  name: 'testproj:testpackage'
});

Package.onUse(function(api) {
  api.versionsFrom('1.1.0.2');

  api.use([
    'mongo@1.1.0',
    'jagi:astronomy@0.12.1',
    'jagi:astronomy-validators@0.10.9'
  ], ['client', 'server']);

  api.addFiles('lib/model.js', ['client', 'server']);

  api.export('testpackage', ['client', 'server']);
});

Package.onTest(function(api) {
  api.use('testproj:testpackage');
  api.use('sanjo:jasmine@0.15.5');

  api.addFiles('tests/jasmine/server/integration/server.js', 'server');
});

I don't remember why you have to do it, but now I remember that I've read about this and you have to do it. It should work. Let me know.

There should be a detailed section in the Meteor docs about creating packages.

lukejagodzinski commented 9 years ago

Maybe it's because in the Astronomy Validators package I use Astronomy in the version 0.10.5 what is wrong. With the next astronomy version I will correct all version numbers.

rhomes-wcd commented 9 years ago

Interesting, I was not aware of this requirement when setting up package.js files. I will test this and get back to you.

EDIT: everything checks out after adding the package version numbers. I appreciate your help!

lukejagodzinski commented 9 years ago

No problem :)