identity-obj-proxy
identity-obj-proxy copied to clipboard
Support Object.prototype.* calls (such as hasOwnProperty).
👋 Hi there!
We have code that looks like this:
import colors from 'colors.less';
function exampleUtilFunction(color) {
if (!colors.hasOwnProperty(color)) {
throw new Error();
}
}
When using this mock, it fails with:
TypeError: colors.hasOwnProperty is not a function
As a quick fix, we added this code to the proxy:
if (key === 'hasOwnProperty') {
return () => true;
}
I think it'd be nice if identity-obj-proxy supported the methods on Object.prototype. I'm happy to submit a PR if it would be accepted. :)