reactjsjestjsamcharts4

Jest - ReferenceError: SVGPathElement is not defined


I'm trying to run a Jest unit test to match snapshot, but there seems to be an issue with am4core. Does anyone have any idea how to solve it?

Test: Test

Error: Error

Thank you


Solution

  • SVGPathElement doesn’t exist on the node. It exists on the browser. Hence add this test

    class SVGPathElement extends HTMLElement {}
    window.SVGPathElement = SVGPathElement
    
    describe('your test', () => {