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: r.node.getBBox is not a function , while running test cases #197
Comments
The error goes away by mocking the library. https://stackoverflow.com/questions/51957794/jest-typeerror-is-not-a-function-in-jest-mock What I did is: 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") }) }) })); |
I was also caught in this error.
My
And, as @ijayoa, @Amitkumarc says, mocks helped me to avoid this error.
Thank you. |
I did managed to get few functionality working by adding mocks to SVGElement.
Right now I am getting error as s[t] is not a function error. If I have this lib imported from source I might get the function name and I can mock it. |
Guys if anyone is tracking is, here is quick update. in latest version of svg.js https://cdnjs.cloudflare.com/ajax/libs/svg.js/3.0.16/svg.js the missing function |
I got same one. The missing function was removed following commit for down package size. My case works with reverting pathHandlers in svg.js. |
@two-pack I moved to cypress completely for unit testing of chart based components. It was easier to test them with rendering them in browser with cypress and quickly write test for them. |
Doesn't that mock the whole library to do nothing? How are your renders still working? |
Is there a fix for this? In 2023 I'm still having problem with this. What can we do related to this? |
hi @junedchhipa ,
I am getting the below errors while running test cases for PieChart react component.
I am using Jest and Enzyme for testing.
While mounting the component:
TypeError: r.node.getBBox is not a function
While calling ApexCharts.exec funtion:
TypeError: Cannot set property 'fillStyle' of null
Can you please tell, how to resolve these issues.
The text was updated successfully, but these errors were encountered: