I have a typescript react app that's using this component, and have a component test for my login component, which is composed of the react-google-login component.
When I run the test (just to see if the component will render) I get the following error:
TypeError: Cannot read property 'parentNode' of undefined.
This seems to be caused by some logic that is intended to insert the Google login script tag before any existing tags in the DOM. If no script tags exist, parentNode is referenced on the zeroth item which is undefined.
I'm not sure of the original intent of this check so I left it and handled this edge case. If the logic is no longer needed I will remove it completely in my PR @anthonyjgrove . Thanks!
PR here:
https://github.com/anthonyjgrove/react-google-login/pull/143
Could mock a script tag to avoid this problem.
const head = document.getElementsByTagName('head')[0]
head.appendChild(document.createElement('script'))
should be fixed now
Most helpful comment
Could mock a
scripttag to avoid this problem.