Allow prop to pass when value is undefined#230
Allow prop to pass when value is undefined#230HookyQR wants to merge 1 commit intoenzymejs:masterfrom
prop to pass when value is undefined#230Conversation
|
React does not differentiate between a prop that’s present and undefined, vs a prop that’s absent. In other words, if the prop is present and undefined, then the props object does not in fact “have” the prop, per react semantics. |
passes. Chai Enzyme should be able to be used to determine if the property (key) is passes, no matter what the value, without having to check ALL props passed. |
|
is |
|
I didn't change https://github.com/producthunt/chai-enzyme/blob/master/src/assertions/props.js#L6 It will also pass the values through the chain, allowing (and requiring) the (as you say) absent value to be checked. An ACTUAL absent prop would not pass the initial test in |
|
Specifically, the PR will allow expect().to.have.prop('third')to have equivalent results to expect().to.have.props(['third'])No matter what the value of |
Reason (see last two tests)
The result of
propsandpropare inconsistent for properties who's values areundefined.I would like to have (give the above example)
to also fail but this may break existing use cases (many tests fail). 😞