Unit testing 如何在ionic 4中编写模态或警报弹出窗口的单元测试

Unit testing 如何在ionic 4中编写模态或警报弹出窗口的单元测试,unit-testing,angular7,ionic4,Unit Testing,Angular7,Ionic4,我想介绍离子4中警报控制器弹出和回调处理程序的单元测试 it('应该打开弹出窗口',()=>{ showAlertPopup(); const popupElem=fixture.debugElement.queryAll(By.css('alert-internal-button'); log('popup元素',popupElem); }); 异步showAlertPopup(){ const警报选项:警报选项={ 消息:“已成功应用”, 按钮:[{ 文本:'是', 处理程序:()=>{

我想介绍离子4中警报控制器弹出和回调处理程序的单元测试

it('应该打开弹出窗口',()=>{
showAlertPopup();
const popupElem=fixture.debugElement.queryAll(By.css('alert-internal-button');
log('popup元素',popupElem);
});
异步showAlertPopup(){
const警报选项:警报选项={
消息:“已成功应用”,
按钮:[{
文本:'是',
处理程序:()=>{
this.router.navigateByUrl('app/home');
}
}]
};
const alert=wait this.alertCtrl.create(alertOpts);
console.log(“警报”,警报);
alert.present();
}

我期望弹出元素,但它未定义。

您得到解决方案了吗?我也面临同样的问题problem@PersianBlue还没有。。。唯一的方法是模拟整个离子警报和模态组件!我在我的项目中就是这样做的。