$browser.$$checkUrlChange is undefined in a jasmine test

浪子不回头ぞ 提交于 2020-01-02 03:41:04

问题


I have the following test:

it('should maintain a bind between the data at the $scope to the data at the ingredientsService', function(){
    $scope.addFilters('val1', $scope.customFiltersData, 'filter1');
    $scope.$digest();
    expect($scope.customFiltersData).toEqual(ingredientsService.filters());
});

I get the following error:

TypeError: undefined is not a function
    at Scope.$digest (/home/oleg/dev/vita-webapp-new/bower_components/angular/angular.js:12502:17)
    at null.<anonymous> (/home/oleg/dev/vita-webapp-new/test/spec/controllers/customfilters.js:92:20)

When debugging I saw that $browser.$$checkUrlChange on line 12502 of angular.js is indeed undefined.

As a temporary solution, I changed the invocation on line 1250 to $browser.$$checkUrlChange && $browser.$$checkUrlChange()

But I cannot help to wonder whether this monkey-patch can hurt me in some other way.

Any clue on how to solve this properly is much appreciated.

In case I do not get my answers I might consider opening a bug at the Angular repo on GitHub.


回答1:


You have a mismatch in the version of angular and angular-mock . See here:

jasmine test fails with undefined is not a function(evaluating $browser.$$checkUrlChange())



来源:https://stackoverflow.com/questions/25917099/browser-checkurlchange-is-undefined-in-a-jasmine-test

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!