我有以下代码
jest.mock('marvel-color-picker', () => {
const MockColorPicker = () => {};
MockColorPicker.prototype.setOptions = () => {};
MockColorPicker.prototype.showOverlay = () => {};
MockColorPicker.prototype.hideOverlay = () => {
};
MockColorPicker.prototype.setElement = () => {};
MockColorPicker.prototype.authContext = () => {};
return { default: MockColorPicker };
});
describe('BrandSetupColor Component', () => {
describe('snapshots', () => {
it('returns component', () => {
const wrapper = shallowWithIntl(<BrandSetupColor authContext={{}} defaultColor="#dddddd" />).dive();
expect(wrapper).toMatchSnapshot();
});
});
describe('behavior', () => {
beforeEach(() => {
jest.resetModules();
});
it('When clicks on color box, calls showOverlay', () => {
const colorPicker = require('marvel-color-picker');
const func = () => {};
const color = shallowWithIntl(<BrandSetupColor authContext={{}} defaultColor="#dddddd" onColor={func} />).dive();
color.find('.js-color').simulate('click');
expect(colorPicker.showOverlay).toHaveBeenCalled();
colorPicker.showOverlay.mockRestore();
});
});
});
我收到错误TypeError: _marvelColorPicker.default is not a constructor
。
有人可以帮忙吗?