Skip to content

Snapshot test recharts plots #1113

Description

@chaoran-chen

Our widget snapshot tests are not covering the plots generated by recharts, the container divs are simply empty:

<div
className="recharts-responsive-container"
style={
Object {
"height": "100%",
"maxHeight": undefined,
"minHeight": undefined,
"minWidth": undefined,
"width": "100%",
}
}
/>
</div>

We should consider testing them. It might, however, not be very easy: when I tried in #1112, I encountered the issue that the tests generated different snapshots on my devince than in the CI.

We should update to recharts v3 (#1111) first.

The following mock snippet might be useful – to be placed under src/__mocks__/recharts:

import React from 'react';

module.exports = {
  ...jest.requireActual('recharts'),
  ResponsiveContainer: ({ children }: { children: any }) =>
    React.cloneElement(React.Children.only(children), { width: 800, height: 400 }),
};

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions