我有一个组件,其中ComponentDidMount试图调用API函数
componentDidMount(){
this.getTypes(this.props.user).then(Response => {this.setState({List: Response.Types })});
}
async getTypes(userLogin){
try{
res = await API.get(......... );
}
catch(error) {
....
}
}
现在我想调用componentDidMount和getTypes并模拟API.get。
因此,有人可以告诉我如何使用Jest调用componentDidMount和getTypes吗?