Calling render() with a component that uses a Line chart fails with the message:
Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.
Check the render method of `TestChart`.
The exact same test using a Bar chart instead of a Line chart passes with no errors. The charts render fine, the error only appears during unit testing.
Current and expected behavior
Calling
render()
with a component that uses aLine
chart fails with the message:The exact same test using a
Bar
chart instead of aLine
chart passes with no errors. The charts render fine, the error only appears during unit testing.Example component:
And example test:
Reproduction
Repro examples provided above
chart.js version
v4.4.0
react-chartjs-2 version
v5.2.0
Possible solution
No response