marchaos / jest-mock-extended

Type safe mocking extensions for Jest https://www.npmjs.com/package/jest-mock-extended
MIT License
836 stars 57 forks source link

feature: allow null and boolean properties #33

Closed nlkluth closed 4 years ago

nlkluth commented 4 years ago

👋 Thanks for you work on this library! I noticed that I cannot set boolean values due to the conditional statement checking for falsey values.

Related Issues

I believe https://github.com/marchaos/jest-mock-extended/issues/30 would be fixed by this change. It appears as though the author is running into the same scenario I did.

The Fix

I changed the condition to check only for undefined, which would allow boolean and null values to be used.

Let me know if there is anything you'd like me to adjust! Thanks 🙌

laurence-hudson-mindfoundry commented 4 years ago

Have also been hitting this bug, would love to see it get merged and make it to a release.

laurence-hudson-mindfoundry commented 4 years ago

if (!(property in obj)) { as suggested in #4 might be an even more robust solution.

nlkluth commented 4 years ago

@laurence-hudson-mindfoundry Good call 👍 Made the change. Let me know if it matches your expectations!

marchaos commented 4 years ago

Hey @nlkluth can you take a look at the conflicts.

nlkluth commented 4 years ago

@marchaos Thanks for knocking that out for me 👍