Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possible to use with global meteor packages? #4

Open
elie222 opened this issue Oct 26, 2017 · 2 comments
Open

Possible to use with global meteor packages? #4

elie222 opened this issue Oct 26, 2017 · 2 comments

Comments

@elie222
Copy link

elie222 commented Oct 26, 2017

We use:
https://github.com/Wylio/meteor-winston-papertrail/

And so we have log global across our code so we can just run log.info('message') wherever we like. However when trying to integrate jest testing this leads to errors of log not found. Any ideas how I can get around this @orangecms?

We have a lot of globals in our app and in many places we don't use import (old Meteor code style).

@orangecms
Copy link
Owner

orangecms commented Oct 27, 2017

Hi @elie222 - thanks for your question!

So, a few things to begin with: Meteor came with its own package ecosystem first before they integrated better with npm. At the same time, they also thought that packages should live in the global scope. So these are two issues now, because when you want to use any other tool for testing, you need to work around that.

You could simply define stubs in a setup file and attach them to the global scope as well. See the Jest docs for details.

However, I strongly advise you to migrate the code and switch to loading modules explicitly. Then you need to solve two issues:

  1. define a stub for the module you are using, as above
  2. override the module loader in the config file to have the stub available as in my README.

Are you still using an older version of Meteor? If so, you should upgrade definitely, because there are also security issues involved.

@elie222
Copy link
Author

elie222 commented Oct 27, 2017 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants