How to write unit test cases for chart components

1 Answer 465 Views
Charts
Ashwini
Top achievements
Rank 1
Iron
Iron
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

Sort by
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.

Regards,
Wissam
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Ashwini
Top achievements
Rank 1
Iron
Iron
commented on 28 Apr 2023, 09:26 AM

Ok Wissam, Thank you.
Wissam
Telerik team
commented on 28 Apr 2023, 10:05 AM

You are welcome, Ashwini!
Tags
Charts
Asked by
Ashwini
Top achievements
Rank 1
Iron
Iron
Answers by
Wissam
Telerik team
Share this question
or