While working on an upgrade to React 18 we were running into some issues with the results of components / bundles loaded via Suspense. After spending a decent amount of time I tracked it down to this repo and a property being accessed that may not exist yet. I also bumped the testcafe version in the package.json to fix build errors with TypeScript, and just have the latest version tested against.
The Bug:
When attempting to find a child of a Suspense, the element for the requested selector inside a ReactSelector may not exist yet, which throws the following error:
1) An error occurred in Selector code:
TypeError: Cannot read properties of undefined (reading 'type')
The Fix:
I tracked it down to the getName function, and have adding a [previously] failing test case, and a fix in the form of an optional chain when accessing that property.
currentElement.type => currentElement?.type
Let me know if I missed something or if I can help provide a better example. Thanks!
Hello!
While working on an upgrade to React 18 we were running into some issues with the results of components / bundles loaded via Suspense. After spending a decent amount of time I tracked it down to this repo and a property being accessed that may not exist yet. I also bumped the testcafe version in the package.json to fix build errors with TypeScript, and just have the latest version tested against.
The Bug:
When attempting to find a child of a Suspense, the element for the requested selector inside a
ReactSelector
may not exist yet, which throws the following error:The Fix:
I tracked it down to the
getName
function, and have adding a [previously] failing test case, and a fix in the form of an optional chain when accessing that property.currentElement.type => currentElement?.type
Let me know if I missed something or if I can help provide a better example. Thanks!