isEmpty will return false if it is passed in undefined, instead of throwing an error.
Summary
If getAnimatedStyle is passed in a component that doesn't have animated styles, it throws an error saying "Cannot convert undefined or null to object". This happens because jestUtils.ts has an isEmpty function that calls Object.keys with an argument that can potentially be undefined. The arg can potentially be undefined because it comes from const jestAnimatedStyleValue = component.props.jestAnimatedStyle?.value;
This issue was introduced in version 3.16.0.
Test plan
Can be simply tested on a browser console. Just run:
isEmpty
will returnfalse
if it is passed inundefined
, instead of throwing an error.Summary
If
getAnimatedStyle
is passed in a component that doesn't have animated styles, it throws an error saying "Cannot convert undefined or null to object". This happens becausejestUtils.ts
has anisEmpty
function that callsObject.keys
with an argument that can potentially beundefined
. The arg can potentially beundefined
because it comes fromconst jestAnimatedStyleValue = component.props.jestAnimatedStyle?.value;
This issue was introduced in version 3.16.0.
Test plan
Can be simply tested on a browser console. Just run:
(obj => Object.keys(obj).length === 0)(undefined) // throws error
(obj => !obj || Object.keys(obj).length === 0)(undefined) // returns true as expected
(obj => !obj || Object.keys(obj).length === 0)({test: 'something'}) // returns false as expected