0
我在使用涉及疊加的離子組件(警報,吐司,模態,動作片)的離子2/3測試組件/頁面遇到問題。當任何代碼調用上述組件的.present()時,出現以下錯誤。離子2/3嘲笑吐司
_getPortal is not a function()
我試過嘲笑適當的控制器,但似乎沒有問題。
任何幫助將不勝感激。
頁代碼
constructor(public navCtrl: NavController, public navParams: NavParams, public viewCtrl: ViewController) {}
save() {
if (this.object.validate()) {
this.provider.save(this.object).then(() => {
}).catch((error) => {
console.log("Error saving object: ", error);
});
} else {
let toast = this.toastCtrl.create({
message: 'All fields (except notes) must be filled before you can save a record',
duration: 3000,
dismissOnPageChange: true,
cssClass: "toastError"
});toast.present();
}}
beforeEach(() => {
fixture = TestBed.createComponent(AddRecordPage);
comp = fixture.componentInstance;
});
afterEach(() => {
fixture.destroy();
comp = null;
de = null;
el = null;
});
,測試這種保存方法將失敗與_getPortal錯誤
更新任何代碼: 我已經再往下隔離,它出現在App對象,因爲這是地方_getPortal拋出錯誤來自;但是,我有我的主要應用對象注入.....
你可以發佈一個頁面的代碼,你可以調用這些組件中的任何一個嗎? –
由於公司政策,我無法發佈整個頁面,但這是失敗的一般方法 –
什麼是「comp」? – Duannx