I have a react class with intl injected like below
import React from 'react';
import { injectIntl } from 'react-intl';
class CanvasView extends React.Component {
constructor(props){
super(props);
this.create = this.create.bind(this);
}
componentDidMount() {
this.create();
}
create(){
// some code
}
render() {
return //something;
}
}
export default injectIntl(CanvasView);
While writing jest test I want to mock the create method.
I tried mocking like this:
CanvasView.prototype.create = jest.fn();
before shallow/mounting the CanvasView class. But, the create method is still being run. This is not mocking the create method since the class is wrapped inside injectIntl, I am not able to mock it.
Please help me to mock this.