How would I test a $scope.watch (AngularJS) change in Jasmine?

后端 未结 1 1212
既然无缘
既然无缘 2021-02-06 22:10

I\'ve just recently started writing something with AngularJS and I\'m not sure how to go about writing a test for this particular thing. I\'m building a \"Help Request\" mode th

1条回答
  •  暗喜
    暗喜 (楼主)
    2021-02-06 22:32

    In your unit tests you need to manually call $scope.$digest() or $scope.$apply() to trigger $scope.$watch().

    Normally in your code you wouldn't have to do this, since directives like ng-click do $rootScope.$apply for you behind the scenes.

    0 讨论(0)
提交回复
热议问题