export class ModalControllerMock {
public create(param1,param2) {
let rtn: Object = {};
rtn['present'] = (() => true);
return rtn;
}; };
someFunc() {
let modal = this.modalController.create(myComp, {
stuff:stuff
});
modal.present();
}
TypeError:undefined不是src / test.ts中的对象(评估'modal.present')(第61262行)
https://github.com/ionic-team/ionic/blob/master/src/components/modal/modal-controller.ts
答案 0 :(得分:0)
找到解决方案:
import {ModalController} from "ionic-angular";
import { mockApp, mockConfig, mockDeepLinker } from 'ionic-angular/util/mock-providers';
export class ModalControllerMock {
constructor() {
return new ModalController(mockApp(), mockConfig(), mockDeepLinker());
}
};
spyOn(modalControllerMock, "create").and.callThrough();