-
Notifications
You must be signed in to change notification settings - Fork 209
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
expect(fn).to.throwError() steals context #106
Comments
👍 |
This is javascript. You can NEVER pass object.method somewhere and expect it will be called with object as "this" argument. |
@shime How is it relevant? Imagine the expect function receiving a parameter. How would you know inside the function if user passed |
I'm not arguing with the implementation - I get why it's like that - it's that the documentation doesn't really provide an example of this assertion being used the way you're likely to want to use it - and the behavior of javascript in this instance isn't super-obvious. I'm pretty sure I made this error report in frustration after beating my head against it for a while, and thought some body else might benefit from my suffering. |
https://gist.github.com/stephenprater/10659056
I would expect this to work - but
j.toJSON
is executed in the context of expect, and not inj
- the work around isThat's pretty unintuitive and not really hinted at by the docs. Although it's probably not possible to know what binding to execute the function in - maybe the docs should indicate you should pass a closure to prevent this.
The text was updated successfully, but these errors were encountered: