This question could also be generalised as - how can I mock out all properties on an imported module to return React components?
This question could also be generalised as - how can I mock out all properties on an imported module to return React components?
The best solution I have so far is:
jest.mock('@material-ui/icons', () => {
const icons = {
__esModule: true,
};
const handler = {
get: function (_, prop) {
return () => <div className={`mock_${prop}Icon`} />;
},
};
return new Proxy(icons, handler);
});