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

Undefined Error using PhantomJS CLI #31

Closed
AdamBrodzinski opened this issue Aug 10, 2014 · 4 comments
Closed

Undefined Error using PhantomJS CLI #31

AdamBrodzinski opened this issue Aug 10, 2014 · 4 comments

Comments

@AdamBrodzinski
Copy link

I'm having issues using PhantomJS and meteor-harmony. When I run my acceptance specs with Meteor-Capybara using PhantomJS it throws the following:

Failures:

  1) Model: Project should switch projects
     Failure/Error: visit root_path
     Capybara::Poltergeist::JavascriptError:
       One or more errors were raised in the Javascript code on the page. If you don't care about these errors, you can ignore them by setting js_errors: false in your Poltergeist configuration (see documentation for details).

       TypeError: 'undefined' is not a function (evaluating 'ModuleStore.register.bind(ModuleStore)')
       TypeError: 'undefined' is not a function (evaluating 'ModuleStore.register.bind(ModuleStore)')
           at http://localhost:3000/packages/harmony.js?d3d1f36ffdf75eff955aee4cc92356d83062d3ce:898
           at http://localhost:3000/packages/harmony.js?d3d1f36ffdf75eff955aee4cc92356d83062d3ce:907
           at http://localhost:3000/packages/harmony.js?d3d1f36ffdf75eff955aee4cc92356d83062d3ce:2135
           at http://localhost:3000/packages/harmony.js?d3d1f36ffdf75eff955aee4cc92356d83062d3ce:2142

Is there anything I can do on my end? Currently i'm using the Chrome browser instead of PhantomJS to get them to run. There's a similar issue filed on Traceur issue 908 but i'm not sure how it applies to Meteor-Harmony

@christianbundy
Copy link
Collaborator

Since this project relies on Traceur, I'm sure that this comment on google/traceur-compiler#908 is the reason it isn't working with PhantomJS.

Although after reading this comment on ariya/phantomjs#10522, it looks like this problem will be solved as soon as PhantomJS makes a new release. Let me know if there's anything else I can help with @AdamBrodzinski!

@AdamBrodzinski
Copy link
Author

Thanks for the quick follow up @christianbundy ! Sounds good, i'll keep an eye on the stable releases and will re-try soon (maybe 2.0 lol).

Feel free to close this since it's not directly related to this repo.

@remcoder
Copy link

remcoder commented Sep 6, 2014

It is actually possible to work around this this easily using Inject-Initial. Just make the server inject the bind polyfill in the HEAD:

Inject.rawHead('injectBind', "<script>if (!Function.prototype.bind) {  Function.prototype.bind = function (oThis) {    if (typeof this !== 'function') {      throw new TypeError('Function.prototype.bind - what is trying to be bound is not callable');    }    var aArgs = Array.prototype.slice.call(arguments, 1),         fToBind = this,         fNOP = function () {},        fBound = function () {          return fToBind.apply(this instanceof fNOP && oThis                 ? this                 : oThis,                 aArgs.concat(Array.prototype.slice.call(arguments)));        };    fNOP.prototype = this.prototype;    fBound.prototype = new fNOP();    return fBound;  };}</script>")

Just put this line somewhere in your server dir or wrap it with Meteor.isServer()

@AdamBrodzinski
Copy link
Author

@remcoder hmmm I added it and it's showing in view source. The bind error went away but now it's throwing the undefined variables for each test. For example, if I have a global object this.Car= {foo: 'bar'} it will say Car is not defined. Bummer!

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

No branches or pull requests

3 participants