私のctrlには、関数が作業を完了した後にページに移動するためのこのコードがあります。
$scope.myFunction = function(){
//other code
window.location.assign(url);
}
私のテストコードは次のようになります。
describe('TEST', function () {
var window;
beforeEach(module(function($provide) {
//dummy window
window = {
location:{href:function(){return 'dummy'},assign:function()
{return 'dummy1'}}
};
// We register our new $window instead of the old
$provide.constant('$window',window);
}));
it("should test",function(){
$scope.myfunction();
});
});
The error that I get is ..Some of your tests did a full page reload! and the test fails.
ここに記載されている問題 ( AngularJS $window サービスの単体テスト)に従いましたが、同じアプローチはうまくいきません。何か案が?