arunoda / laika

testing framework for meteor
http://arunoda.github.io/laika/
MIT License
242 stars 38 forks source link

Possible to pass function into client evalSync? #126

Open ghost opened 10 years ago

ghost commented 10 years ago

From what I understand of the code, it's not possible to pass functions as parameters into evalSync for the client... because the parameters eventually get stringified by phantom and that means only valid JSON types can be passed.

I'm trying to achieve something like this...

helpers = require("./lib/helpers.js");
...
client.evalSync(function() {
    helpers.initialise();
    emit("return");
});

Obviously this isn't going to work, because "helpers" isn't defined after the evalSync function is injected. I don't want to put the emit in the helpers.initialise function because I'm trying to keep my library code free from the concept of Laika. I tried some closure tricks, but I always ended up clobbering the scope for either 'helpers.initialise' or the 'emit'.

Hoping for some input on this one.