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

TypeError: 'undefined' is not a function #292

Closed
barmstrong opened this Issue Apr 11, 2013 · 8 comments

Comments

Projects
None yet
9 participants
@barmstrong

barmstrong commented Apr 11, 2013

I get this error when running my test:

     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 'function(e) {
                    this.visible = true;
                    this.update(e)
                }.bind(this)')
           at http://127.0.0.1:59232/assets/rickshaw.js:1729
           at http://127.0.0.1:59232/assets/rickshaw.js:1562
           at http://127.0.0.1:59232/assets/rickshaw.js:174 in klass
           at http://127.0.0.1:59232/assets/rickshaw.js:2705
           at http://127.0.0.1:59232/assets/jquery.js:975
           at http://127.0.0.1:59232/assets/jquery.js:1085
           at http://127.0.0.1:59232/assets/jquery.js:407
           at http://127.0.0.1:59232/assets/jquery.js:84

But this error doesn't show up when I visit the page at localhost:3000 in development (nothing in the chrome javascript console). So I'm not sure why it's happening during the test. Could the load order of jquery etc be different in the test environment? (this is rails). In development jquery loads before rickshaw, but I'm not sure I'm reading the output correctly above that this is showing load order.

Any other ideas?

@jonleighton

This comment has been minimized.

Contributor

jonleighton commented Apr 13, 2013

The output doesn't show the load order, it shows the backtrace. It looks like jquery is loaded.

PhantomJS currently uses an older version of WebKit which does not support Function.prototype.bind. That's your problem. (There are efforts to get a new WebKit version in PhantomJS but it's not done yet.)

@stevenyxu

This comment has been minimized.

stevenyxu commented Apr 23, 2013

I ran into this myself using Foundation. I homebrewed a basic implementation of bind and threw it in before the offending code and poltergeist runs fine:

if(typeof Function.prototype.bind == 'undefined') {
  Function.prototype.bind = function(target) {
    var f = this;
    return function() {
      f.apply(target, arguments);
    };
  };
}

@jarthod jarthod referenced this issue Sep 6, 2013

Open

Ensure degradation upon error. #90

0 of 3 tasks complete
@bobbytables

This comment has been minimized.

bobbytables commented Jan 29, 2014

I'm seeing this with Foundation and React too.

@vpivo

This comment has been minimized.

vpivo commented Feb 4, 2015

I'm also having issues with React. I'm trying to run functional tests so I can't directly change the code. I writing a prototype bind script and using poltergeistjs run with no luck. Any idea?

@yaauie

This comment has been minimized.

Member

yaauie commented Feb 5, 2015

@AmyPivo have you tried using the implementation of Function.prototype.bind submitted by @cairo140 above? Perhaps providing additional information can help isolate the problem (e.g., ruby, poltergeist, phantomjs versions, failure backtraces, etc.).

This specific ticket is closed, has been for a long time, and no new information has been added to indicate that the initial resolution was invalid; it may be best to provide a wholly new bug report (with complete, minimal reproduction steps) and to reference this one if you think they're related.

@nrevko

This comment has been minimized.

nrevko commented Mar 7, 2015

@cauro140 suggestion almost worked for me, but had to add return:

        if(typeof Function.prototype.bind == 'undefined') {
          Function.prototype.bind = function(target) {
            var f = this;
            return function() {
              return f.apply(target, arguments);
            };
          };
        }
@kalashnikovisme

This comment has been minimized.

kalashnikovisme commented Nov 30, 2015

same problem

@twalpole

This comment has been minimized.

Contributor

twalpole commented Dec 1, 2015

@kalashnikovisme You're commenting on an issue that has been closed for over 2 years, with no version info, and no actual details. If you actually have a real problem please open a new issue with all relevant details and a minimal example that shows the problem

ixti added a commit to sensortower/sidekiq-throttled that referenced this issue Apr 2, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment