diff --git a/src/to-have-text-content.ts b/src/to-have-text-content.ts index 6a7e51b..a8da0c5 100644 --- a/src/to-have-text-content.ts +++ b/src/to-have-text-content.ts @@ -9,7 +9,7 @@ function collectNormalizedText(element: ReactTestInstance) { function collectChildrenText(element: ReactTestInstance | string): string[] { if (typeof element === 'string') return [element]; - if (!element || !element.children) return []; + if (!element?.children) return []; const result: string[] = []; element.children.forEach((child) => {