TypeError: clone.node.getBBox is not a function

See original GitHub issue

Hi, I have a console warning I was hoping someone could help me with. When using apex charts heatmap I get a long callstack console warning. I’m doing a smoke test on the component with jest to make sure it renders properly. I also tested for the example code for React heatmap on the apex charts webpages and I get same warning.

console.warn node_modules/apexcharts/dist/apexcharts.common.js:14260 TypeError: clone.node.getBBox is not a function at new create (path\node_modules\apexcharts\dist\apexcharts.common.js:21109:30)

And then the callstack continues a bit before another warning:

console.warn node_modules/apexcharts/dist/apexcharts.common.js:14260 TypeError: this.node.getScreenCTM is not a function at create.screenCTM (path\node_modules\apexcharts\dist\apexcharts.common.js:21342:41)

And the callstack continues again.

Anyone have an idea of what might be the problem?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:2
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

10reactions
karesztrkcommented, May 20, 2021

For anybody who is looking for mocks to suppress this warning. You can also add jest-canvas-mock if you need a proper implementation behind the scenes.

Object.defineProperty(global.SVGElement.prototype, 'getScreenCTM', {
  writable: true,
  value: jest.fn(),
});

Object.defineProperty(global.SVGElement.prototype, 'getBBox', {
  writable: true,
  value: jest.fn().mockReturnValue({
    x: 0,
    y: 0,
  }),
});

Object.defineProperty(global.SVGElement.prototype, 'getComputedTextLength', {
  writable: true,
  value: jest.fn().mockReturnValue(0),
});

Object.defineProperty(global.SVGElement.prototype, 'createSVGMatrix', {
  writable: true,
  value: jest.fn().mockReturnValue({
    x: 10,
    y: 10,
    inverse: () => {},
    multiply: () => {},
  }),
});
6reactions
junedchhipacommented, Aug 10, 2020

Other users have fixed this error by mocking ApexCharts in their tests

import ApexCharts from "apexcharts";
import ReactApexChart from "react-apexcharts";`

jest.mock("react-apexcharts", () =>
  jest.fn(() => {
    return null;
  })
);
jest.mock("apexcharts", () => ({
  exec: jest.fn(() => {
    return new Promise((resolve, reject) => {
      resolve("uri");
    });
  })
}));

https://github.com/apexcharts/ng-apexcharts/issues/48#issuecomment-667124436 https://github.com/apexcharts/react-apexcharts/issues/197#issuecomment-660125576

Read more comments on GitHub >

github_iconTop Results From Across the Web

TypeError: r.node.getBBox is not a function".] { code ...
For anybody who is looking for mocks to suppress this warning. Object.defineProperty(window, 'ResizeObserver', { writable: true, ...
Read more >
SVGGraphicsElement.getBBox() - Web APIs | MDN
The SVGGraphicsElement.getBBox() method allows us to determine the coordinates of the smallest rectangle in which the object fits.
Read more >
How can we mock bpmn-js in jest for unit testing? - General
Though i am getting TypeError: this.getDefaultLayer(...).getBBox is not a function error. so probably i think we need to mock the bpmn-js.
Read more >
Where's getBBox? / Iain Dillingham - Observable
function myFunction(selection) { ; var bbox = selection.node().getBBox(); // This line errors on Firefox. ; selection.text(`${bbox} width: ${bbox.width}, height: ...
Read more >
getBBox is not a function - GSAP - GreenSock
When I do not include an align parameter the animation plays normally with code below. ... getBBox is not a function ... TypeError:...
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