Hi, I’m building application using Mantra and I set up a mocha testing the same way as in mantra-sample-blog-app, so the testing tools (mocha, …) are from npm. But I have a problem with importing meteor packages. I’m testing module’s actions and the actions file imports a meteor package import {SimpleSchema} from 'meteor/aldeed:simple-schema'
. When I run mocha, it will complain Error: Cannot find module 'meteor/aldeed:simple-schema'
. Do you know how to solve it? Thanks
Did you install aldeed:simple-schema package before trying to use it?
Yes, the application work fine, only the tests not.
I can say that packages from npm work fine in tests, the meteor packages have a problem.
Yes. Mantra use pure NPM tools to test. So, it can’t see Meteor packages. You should not use Meteor packages and in actions, components or containers.
You should use Meteor packages only in the context.js
and use dependency injection to get their functionality. Then you can mock them.
Thanks, you mean it can see NPM packages only, don’t you?
Oops. Yes. It can’t see Meteor packages. I’ll update it.