Closed gotoAndBliss closed 10 years ago
is it possible that this is an asynchronous issue, eg, this
does not have the proper method at runtime but when you log it out, the method has resolved on the context of this by the time you are looking for it?
Hmm.. how could I find out? The console is produced by Teaspoon itself, so I figured that this
would be the same one that it fails on.
How is this Teaspoon? You say "Teaspoon is not happy about passing .bind()", yet I see nothing in your code that's at all related to Teaspoon.
What it looks like, is that bind isn't being loaded into your test environment. So the question should be:
Where is the bind method coming from, and why isn't it defined?
If you figure that out, you will solve your issue. Again, this doesn't seem like anything related to Teaspoon, and I apologize if you can show me otherwise.
Ok, I did some quick research.. I'd guess you're trying to use the ECMA-5.1 implementation.. which isn't supported everywhere -- and apparently not in phantomjs yet either?
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind
That link provides a polyfill, which you'll need to load. And you should consider loading that anyway, otherwise your JS won't work properly in some clients.
If you don't want to load the polyfill, you might want to consider using selenium as your driver (instead of phantomjs), as that might give you more expected results since I'd also guess you're only checking things in FF.
Am I at least close to understanding your issue?
You were totes justified to close it before. With good reason. Its not Teaspoon's fault. It's my driver.
But nonetheless, I can't thank you enough for the advice. I am absolutely grateful. Thank you very very much!
I have this inside my file.js..
Which Teaspoon returns as..
So I added a few console.log()'s and got the following to work properly..
But what breaks is when I .bind(this) to receiveMessage which is required so that I can still reference
this
from within the method..So seeing that Teaspoon isn't cool with this.. is there a way I can just stub that method with a spy? I tried this..
But Teaspoon still returns the same error as it seems to be breaking the entire javascript rather than stepping over it because it was stubbed.
Any suggestions or ideas would be greatly appreciated. Thanks!