-
Notifications
You must be signed in to change notification settings - Fork 142
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
Consider using _.isObjectLike rather than _.isPlainObject within td.object #224
Comments
I think you are probably right and that However, I'd like to understand why |
I dunno. I guess I could go either way after writing this out: const mock = td.constructor(MyClass);
callDoSomething(new mock());
td.verify(mock.prototype.doSomething()); |
Hmm, there are really three affected areas by this distinction and I think it warrants some thinking before we change anything.
|
hmm, this isn't quite an obvious fix. If we just swap Probably need to spend a little more time looking at this… |
I've had the night to reflect on this and I think I want to recommend using Instead, I'm going to suggest we "fix" this by improving the message. |
Okay, #224 should be complete with this change: * Get rid of one-off prototypal function name finder (in favor of the single gatherProps + filterFunctions functions) * There was a bug in the replace-test that was somehow erroneously passing in phantom before but this irritated it somehow (phantom 2.1.1 doesn't even support the class keyword), so I had to add a flag to ignore the test under phantom—still passed under Chrome FWIW.
Closing in favor of the approach taken in #264 |
Given this code:
When run on a browser that doesn't support proxies - such as IE11 - this code will throw an error saying:
I believe this to be a false positive, with the offending code being
testdouble.js/src/object.js
Line 16 in c54b741
This code uses
_.isPlainObject
, which returns false for instances of objects whose[[Prototype]]
is notObject.prototype
. This is problematic for instances of classes, who's[[Prototype]]
is the constructor.I'm wondering if you'd be willing to switch to _.isObjectLike instead of
isPlainObject
? This will returnfalse
for functions / constructors, buttrue
for instances.I'm able to work around the
_.isPlainObject
limitation by creating a fake constructor usingtd.constructor
, and then instantiating that instead, but it is a bit more boilerplate.Thanks!
The text was updated successfully, but these errors were encountered: