Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError invoking getElementsByName and getTotalLength #17

Closed
alexieyizhe opened this issue Jul 29, 2018 · 1 comment
Closed

TypeError invoking getElementsByName and getTotalLength #17

alexieyizhe opened this issue Jul 29, 2018 · 1 comment

Comments

@alexieyizhe
Copy link

alexieyizhe commented Jul 29, 2018

While using Jest + Enzyme/ReactTestRenderer, I encountered the two following errors:

Renderer:

TypeError: Cannot read property 'getElementsByTagName' of null

      at MtSvgLines.selectPathElems (node_modules/react-mt-svg-lines/lib/index.js:282:36)
      at MtSvgLines.getPathLengths (node_modules/react-mt-svg-lines/lib/index.js:373:28)
      at MtSvgLines.animate (node_modules/react-mt-svg-lines/lib/index.js:229:34)
      at MtSvgLines.componentDidMount (node_modules/react-mt-svg-lines/lib/index.js:96:12)
      at node_modules/react-test-renderer/lib/ReactCompositeComponent.js:262:25
      at measureLifeCyclePerf (node_modules/react-test-renderer/lib/ReactCompositeComponent.js:73:12)
      at node_modules/react-test-renderer/lib/ReactCompositeComponent.js:261:11
      at CallbackQueue.notifyAll (node_modules/react-test-renderer/lib/CallbackQueue.js:74:22)
      at ReactTestReconcileTransaction.close (node_modules/react-test-renderer/lib/ReactTestReconcileTransaction.js:34:26)
      at ReactTestReconcileTransaction.closeAll (node_modules/react-test-renderer/lib/Transaction.js:207:25)
      at ReactTestReconcileTransaction.perform (node_modules/react-test-renderer/lib/Transaction.js:154:16)
      at batchedMountComponentIntoNode (node_modules/react-test-renderer/lib/ReactTestMount.js:67:27)
      at ReactDefaultBatchingStrategyTransaction.perform (node_modules/react-test-renderer/lib/Transaction.js:141:20)
      at Object.batchedUpdates (node_modules/react-test-renderer/lib/ReactDefaultBatchingStrategy.js:60:26)
      at Object.batchedUpdates (node_modules/react-test-renderer/lib/ReactUpdates.js:95:27)
      at Object.render (node_modules/react-test-renderer/lib/ReactTestMount.js:126:18)
      at Object.<anonymous> (tests/PageFooter.test.js:28:32)

Enzyme (same as #11 ):

TypeError: pathEl.getTotalLength is not a function

      at node_modules/react-mt-svg-lines/lib/index.js:375:89
          at Proxy.map (<anonymous>)
      at MtSvgLines.getPathLengths (node_modules/react-mt-svg-lines/lib/index.js:374:21)
      at MtSvgLines.animate (node_modules/react-mt-svg-lines/lib/index.js:229:34)
      at MtSvgLines.componentDidMount (node_modules/react-mt-svg-lines/lib/index.js:96:12)
      at node_modules/react-dom/lib/ReactCompositeComponent.js:262:25
      at measureLifeCyclePerf (node_modules/react-dom/lib/ReactCompositeComponent.js:73:12)
      at node_modules/react-dom/lib/ReactCompositeComponent.js:261:11
      at CallbackQueue.notifyAll (node_modules/react-dom/lib/CallbackQueue.js:74:22)
      at ReactReconcileTransaction.close (node_modules/react-dom/lib/ReactReconcileTransaction.js:78:26)
      at ReactReconcileTransaction.closeAll (node_modules/react-dom/lib/Transaction.js:207:25)
      at ReactReconcileTransaction.perform (node_modules/react-dom/lib/Transaction.js:154:16)
      at batchedMountComponentIntoNode (node_modules/react-dom/lib/ReactMount.js:124:15)
      at ReactDefaultBatchingStrategyTransaction.perform (node_modules/react-dom/lib/Transaction.js:141:20)
      at Object.batchedUpdates (node_modules/react-dom/lib/ReactDefaultBatchingStrategy.js:60:26)
      at Object.batchedUpdates (node_modules/react-dom/lib/ReactUpdates.js:95:27)
      at Object._renderNewRootComponent (node_modules/react-dom/lib/ReactMount.js:317:18)
      at Object._renderSubtreeIntoContainer (node_modules/react-dom/lib/ReactMount.js:399:32)
      at Object.render (node_modules/react-dom/lib/ReactMount.js:420:23)
      at Object.render (node_modules/enzyme-adapter-react-15/build/ReactFifteenAdapter.js:181:50)
      at new ReactWrapper (node_modules/enzyme/build/ReactWrapper.js:98:16)
      at mount (node_modules/enzyme/build/mount.js:19:10)
      at Object.<anonymous> (tests/PageFooter.test.js:22:14)

I'm using react-mt-svg-lines 0.8.4, and right now I'm working around this issue by safely accessing getElementsByTagName through this change to line 282 in index.js:
var svgEl = this._svgWrapper && this._svgWrapper.getElementsByTagName('svg')[0];

@moarwick
Copy link
Owner

moarwick commented Aug 1, 2018

k, don't have a quick way to test it with Enzyme/ReactTestRenderer but your guard looks good. implemented in 0.8.5. will need to make a larger update for React 17 soon, so perhaps will find some time to add Jest/Enzyme then..

@moarwick moarwick closed this as completed Aug 1, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants