arunoda / laika

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

Adding Client-side Helpers Within PhantomJS #133

Open iansinnott opened 10 years ago

iansinnott commented 10 years ago

There doesn't seem to be a good way to hook into PhantomJS and add custom code. Maybe this could be accomplished by adding an onInitialized callback to the PhantomJS instance. This would be a huge improvement and would probably solve quite a few of the open issues here.

For anyone who needs to include helpers on the client side now, you can just put them in your client-side meteor code:

// client/helpers/phantom_helpers.js
if (window.callPhantom) {
  domHelper = function() {
    return 'stuff...';
  };
}

This is still ugly since all test code should really go under tests/, not client/, but it's a quick workaround until there is better method.

ghost commented 10 years ago

There is way you can keep your helpers in tests/ but it's a little messy.

I just toString all of my helpers, passed it as a parameter to evalSync and then eval on the other side.