-
Notifications
You must be signed in to change notification settings - Fork 22
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
Comments
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:
Are you still using an older version of Meteor? If so, you should upgrade definitely, because there are also security issues involved. |
We're on the most recent version of Meteor. But we still use globals for
half the app or so. The parts I'm adding tests to we use the imports folder
for. But even here there are still some globals (such as the logger I
linked to).
Thanks for the detailed response. I'll continue trying to make it work. I
was close to having it working, but failed on stubbing the final pieces.
I'll take a look at the Jest docs you linked to.
…On 27 Oct 2017 10:01 am, "Daniel Maslowski" ***@***.***> wrote:
Hi @elie222 <https://github.com/elie222> - thanks for you 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
<https://facebook.github.io/jest/docs/en/configuration.html#setuptestframeworkscriptfile-string>
for details.
However, I strongly advise you to migrate the code and switch to loading
modules explicitly. Then you need to solves 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
<https://github.com/orangecms/jest-meteor-stubs/blob/master/README.md#usage>
.
Are you still using an older version of Meteor? If so, you should upgrade
definitely, because there are also security issues involved.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#4 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AC8oX6fXFeS_xFJHDPcnQJOSyvz07-hEks5swX_ggaJpZM4QIOBE>
.
|
We use:
https://github.com/Wylio/meteor-winston-papertrail/
And so we have
log
global across our code so we can just runlog.info('message')
wherever we like. However when trying to integratejest
testing this leads to errors oflog
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).The text was updated successfully, but these errors were encountered: