diff --git a/src/helpers/getByAPI.js b/src/helpers/getByAPI.js index 91b131a08..28685ff29 100644 --- a/src/helpers/getByAPI.js +++ b/src/helpers/getByAPI.js @@ -20,8 +20,10 @@ const getNodeByText = (node, text) => { const isTextComponent = filterNodeByType(node, Text) || filterNodeByType(node, TextInput); if (isTextComponent) { - const textChildren = React.Children.map(node.props.children, child => - child.toString() + const textChildren = React.Children.map( + node.props.children, + // In some cases child might be undefined + child => (child ? child.toString() : '') ); if (textChildren) { const textToTest = textChildren.join('');