angularjs - how to mock ngModel? -
so testing controller, referencing property specified ngmodel in dom. while testing controller, don't have template. whenever $scope.foo.property being accessed in controller, throws error.
in test, can define property before instantiate controller :
it('should mock ng-model', inject(function($rootscope, $controller) { $rootscope.foo = { property: 'mock value' }; $controller('mycontroller', {$scope: $rootscope}); })));
Comments
Post a Comment