Ashwini
asked on 26 Apr 2023, 01:04 PM
| edited on 27 Apr 2023, 05:41 AM
How I can I write unit test cases for chart components. For example, I have pasted one screenshot for seriesVisual. By mocking data it is not covered in coverage. I am using react-testing-library and jest for writing test cases.
1 Answer, 1 is accepted
0
Wissam
Telerik team
answered on 28 Apr 2023, 09:02 AM
Hello, Ashwini,
We currently do not have any suggestions or documentation that we can provide for testing for the KendoReact Chart component, especially since it uses SVG for the rendering.
However, we are aware of some limitations regarding the Chart and react-test-renderer "create" method for example, which is related to the fact that the Chart relies heavily on the browser API for drawing the component, and even with a virtual DOM-like (jsdom) it's hard to mock all available browser APIs needed to create a Chart.
Additionally, some testing libraries require that each element have an explicit ID, which in the context of the KendoReact components is not supported for complex components.
With the above in mind, I recommend testing the Chart with e2e or integration tests, instead of unit tests.
Please let me know if you have any further questions on this matter.