-
-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Unable to render LineChart on React Testing Library #2232
Comments
Having the same issue here. I am rendering the line chart as a story in storybook and everything is working great there, but when I try to render the same story with jest, all I get is an empty div like above. |
Bump. We have our graphs working for our data visualizations but are unable to regression test using react-testing-library. |
I think the reason is here https://github.com/plouc/nivo/blob/master/packages/core/src/components/ResponsiveWrapper.js The responsive measure not work with Jest environment so width & height always are 0 then nothing are rendered So I found a solution that is mocking jest.mock("@nivo/core", () => ({
...jest.requireActual("@nivo/core"),
ResponsiveWrapper: ({ children }: any) =>
children({ width: 400, height: 400 }),
})); Then it worked |
Great @beohoang98! thank you |
This issue has been automatically marked as stale. If this issue is still affecting you, please leave any comment (for example, "bump"), and we'll keep it open. We are sorry that we haven't been able to prioritize it yet. If you have any new additional information, please include it with your comment! |
Description
Unable to render LineChart inside React Testing Library
Reproduce
The DOM rendered does not contain the chart:
Expected behavior
It should be rendered by the React Testing Library on the jsdom environment
Desktop (please complete the following information):
The text was updated successfully, but these errors were encountered: