Hi everyone,
I am writing a Meteor package and I want to test it using Mocha, Chai, Sinon and some Chai plugins (e.g. Chai as Promised) as well. The Mocha and Chai version in the practicalmeteor:x
wrappers are very out-of-date, so I wanted to depend on the source npm packages directly. I got it working with the practicalmeteor:mocha
driver, using the following package.js
Npm.depends({
"simpl-schema": "0.2.3",
"lodash.uniq": "4.5.0",
"lodash.uniqby": "4.7.0",
"lodash.isempty": "4.4.0",
"mocha": "3.2.0",
"chai": "3.5.0",
"sinon": "2.1.0",
})
Package.onUse(function(api) {
api.versionsFrom('1.4.2.3');
api.use(['ecmascript', 'mongo', 'accounts-base@1.2.15']);
api.mainModule('client/main.js', 'client');
api.mainModule('server/main.js', 'server');
});
Package.onTest(function(api) {
api.use('username:package');
api.use(['ecmascript', 'practicalmeteor:mocha']);
api.mainModule('tests/client.js', 'client');
api.mainModule('tests/server.js', 'server');
});
However, I don’t want to include the testing libraries (essentially the devDependencies
) in the package code. So, as per this suggestion, I tried listing the npm dependencies both under Package.onTest
and Package.onUse
:
Package.onUse(function(api) {
api.versionsFrom('1.4.2.3');
Npm.depends({
"simpl-schema": "0.2.3",
"lodash.uniq": "4.5.0",
"lodash.uniqby": "4.7.0",
"lodash.isempty": "4.4.0",
})
api.use(['ecmascript', 'mongo', 'accounts-base@1.2.15']);
api.mainModule('client/main.js', 'client');
api.mainModule('server/main.js', 'server');
});
Package.onTest(function (api) {
Npm.depends({
"simpl-schema": "0.2.3",
"lodash.uniq": "4.5.0",
"lodash.uniqby": "4.7.0",
"lodash.isempty": "4.4.0",
"mocha": "3.2.0",
"chai": "3.5.0",
"sinon": "2.1.0",
});
api.use('username:package');
api.use(['ecmascript', 'practicalmeteor:mocha']);
api.mainModule('tests/client.js', 'client');
api.mainModule('tests/server.js', 'server');
});
However, it leads to an inifinite loop:
[[[[[ Tests ]]]]]
=> Started proxy.
=> Started MongoDB.
username:package: updating npm dependencies -- simpl-schema, lodash.uniq, lodash.uniqby, lodash.isempty...
local-test:username:package: updating npm dependencies -- simpl-schema, lodash.uniq, lodash.uniqby, lodash.isempty, mocha, chai,
sinon...
username:package: updating npm dependencies -- simpl-schema, lodash.uniq, lodash.uniqby, lodash.isempty...
local-test:username:package: updating npm dependencies -- simpl-schema, lodash.uniq, lodash.uniqby, lodash.isempty, mocha, chai,
sinon...
username:package: updating npm dependencies -- simpl-schema, lodash.uniq, lodash.uniqby, lodash.isempty...
local-test:username:package: updating npm dependencies -- simpl-schema, lodash.uniq, lodash.uniqby, lodash.isempty, mocha, chai,
sinon...
How can I Npm.depends
packages that should only be included in the tests?
Thanks in advance for any help you are able to provide.