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
Components returning undefined rather than empty string for false #74
Comments
Hi @ShaneDrury! As you say I'm checking for exports[`falsey case 1`] = `undefined`; it should give exports[`falsey case 1`] = `false`; I will have a look but I think I will stick to an empty string for |
I'm still reproducing something similar (or the same?) with 3.1.2 <div styleName="CarouselDot__inner">
{!!icon && <Icon styleName="CarouselDot__icon" name={icon} />}
</div> When
If I change it to The weird thing is that my whole project makes use of renders of this kind, and only this component gives me this problem. Ideas? |
Hey @FezVrasta, that's my bad, I haven't released a new version including the fix. I'll get v3.1.3 out asap. |
@FezVrasta v3.1.3 is out! |
Thank you! |
Nope, no way... I'm getting the same problem of before even with 3.1.3... I double checked it 😓 Note that my component doesn't return just |
@FezVrasta I will have a look now. |
I'm going to send a PR to add a failing test, if I manage to get one. |
Don't worry I just reproduced the issue so I have a failing test. Thanks for reporting the issue by the way. |
Oh, I just finished the PR lol. nevermind then 😇 |
Haha sorry, good news is that I fixed it already. |
@FezVrasta it should be fixed in |
It works ❤️ |
Hey, I'm not sure if this is a bug but there seems to be some inconsistency between the code and described behaviour.
In the recent version 3.0 upgrade Issue #67, one of the breaking changes is: "Components returning null or any falsy value are now rendered as an empty string in snapshots instead of null"
But that doesn't seem to be what's happening in the code.
A simple failing case:
gives
where I would expect
falsey case
to return the empty string.I think this is because we're using
lodash
'sisNil
to check return values hereenzyme-to-json/src/shallow.js
Line 39 in 810b38a
which "Checks if value is null or undefined." but not
false
: https://lodash.com/docs/4.17.4#isNilIs using
isNil
desired behaviour? Thanks for your timeThe text was updated successfully, but these errors were encountered: