You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
lukecoursey
changed the title
[Bug]: "Element is invalid" when testing Line chart with react testing library
[Bug]: "Element type is invalid" when testing Line chart with react testing library
Jul 1, 2024
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
The text was updated successfully, but these errors were encountered: