-
Notifications
You must be signed in to change notification settings - Fork 28
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
[Meteor] global server variable not global to mocha files #29
Comments
Comment by Sanjo You can use the before hook to do stuff before the tests run: https://mochajs.org/#hooks. |
Comment by brucejo75 Thanks for responding @sanjo.
The problem is I need access to the Is it a hard constraint that Thanks! |
Comment by samhatoum According to this line, it should be available to you globally https://github.com/xolvio/chimp/blob/master/src/lib/chimp-helper.js#L66 However for the mocha helper, we only call the helpers and such in a before block: https://github.com/xolvio/chimp/blob/master/src/lib/mocha/mocha-helper.js#L9 which means it's simply not ready by the time you try. Perhaps you might get away with removing the before block here: Try forking the repo and removing that line. If it works, let us know :) |
Comment by brucejo75 Thanks for the pointer. I tried pulling the code out of the In essence, this line: I am a little out of my depth here, but I think there may be a couple of options:
Thanks for any input. Console Output
|
Comment by brucejo75 Well, I could not leave it alone :-). I put all the init steps into a function and I tried to find any mocha event hooks that would be called after Mocha is initialized and ready to start running. I could not find anything. I did find this thread kind of addressing the issue. But the problem for us is that If you can point me in some more useful directions, I will take a look. |
Comment by samhatoum This is not a trivial one I'm afraid and without investing a lot of time it'll be hard for us to help much. You can try to use the We can offer paid support if you guys desperately need this. I've also marked this as help-wanted in case anyone out there would like to invest the time! |
Issue by brucejo75
Friday Apr 29, 2016 at 04:56 GMT
Originally opened as xolvio/chimp#355
I am trying to use the
server
global to initialize data for all of my tests outside of an it block. This becomes quite useful if you use a data pattern to create the tests. My example is to get the users DB and create a test to verify each user.Is there some reason why
server
is only available in anit
block? It took me 3-4 hrs to realize this limitation when I first started to use chimp.Plus I am unable to create any sort of workaround. Frustrating.
Thanks!
Expected behaviour
I expect to be able to reference the global
server
variable in any scope within a mocha file. It is global after all.Actual behaviour
The global
server
variable is only defined within a test (it
block).Steps to reproduce the problem
try to use the global
server
variable outside of anit
block and you will find it is undefined.Used version
Console / Log Output
N/A
The text was updated successfully, but these errors were encountered: