question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

.getTotalLength is not a function

See original GitHub issue

getting this error during tests: (Seems to be related to #72)

TypeError: _c.getTotalLength is not a function

...
      at Object.getPosition (node_modules/.pnpm/registry.npmjs.org+react-xarrows@2.0.2_react@16.13.1/node_modules/react-xarrows/lib/index.js:1124:90)
      at node_modules/.pnpm/registry.npmjs.org+react-xarrows@2.0.2_react@16.13.1/node_modules/react-xarrows/lib/index.js:180:37
      at commitHookEffectListMount (node_modules/.pnpm/registry.npmjs.org+react-dom@16.13.1_react@16.13.1/node_modules/react-dom/cjs/react-dom.development.js:19731:26)

version: 2.0.2 using Jest and react testing library.

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:1
  • Comments:7

github_iconTop GitHub Comments

5reactions
robertpincommented, May 31, 2022

I was able to bypass it by mocking the component (I prefer not to conditionally render it based on the NODE_ENV).

jest.mock('react-xarrows', () => {
  return {
    __esModule: true,
    default: () => <span />,
    useXarrow: () => null,
  };
});
1reaction
maxPiroddicommented, May 20, 2022

Seems to still be no updates on this one…

For the time being, I have been working around it similar to DiaconuDan

{process.env.NODE_ENV !== 'test' && <Xarrow ... />

But definitely not an ideal solution!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Can't get getTotalLength() from <path> [closed] - Stack Overflow
You are trying to create a normal HTML-Element called path , which does not have any function called path.getTotalLength() . Try document.
Read more >
getTotalLength() is no longer supported · Issue #155 - GitHub
getTotalLength() has been removed from the Web standards. ... setDashoffset causes "getTotalLength is not a function" error on svg circle ...
Read more >
SVGGeometryElement.getTotalLength() - Web APIs | MDN
The SVGGeometryElement.getTotalLength() method returns the user agent's computed value for the total length of the path in user units.
Read more >
getTotalLength() example - CodePen
Example of how to get a SVG paths length...
Read more >
typeerror: e.gettotallength is not a function syncfusion - You.com
You are trying to create a normal HTML-Element called path , which does not have any function called path.getTotalLength() . Try document.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found