Javascript.confirm() and Angularjs Karma e2e test

后端 未结 3 391
暖寄归人
暖寄归人 2021-02-05 15:44

I have an Angularjs application that uses simple javascript confirm before executing some actions.

Controller:

function TokenControll         


        
3条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-02-05 16:10

    Another option would be to directly create a spy and automatically return true:

    //Jasmine 2.0
    spyOn(window, 'confirm').and.callFake(function () {
         return true;
    });
    
    //Jasmine 1.3
    spyOn(window, 'confirm').andCallFake(function () {
         return true;
    });
    

提交回复
热议问题