我有一个方法,在执行几行代码后调用promise-
const handleDownload = () =>{
if(!currentItem){
return;
}
setDownloadState(true);
setDeleteState(false);
Task.DeleteAttachment(currentItem.FileId)
.then((res)=>{
if(res.status===200){
...
...
...
}
else{
dispatch(MarkError(true));
}
})
.catch((error)=>{
dispatch(ReportError(error));
});
}
.then((res)=>{
之前的所有行都包含在测试覆盖报告中。但是promise then和catch没有包含在内。
我怎样才能覆盖它们?
1条答案
按热度按时间b91juud31#
在您的测试用例中,您可以使用async await: