All Questions
45 questions
1
vote
2
answers
900
views
Jasmine spyOn not working properly on AngularJS directive
I'm working on an AngularJS app and I'm facing some problems with Jasmine's SpyOn in a concrete directive.
The directive is quite simple, just call a service's method and when it resolves/rejects the ...
1
vote
1
answer
316
views
Angular Directive function not being called in Unit Testing
I built a new directive in Angular (1.2.29) and I am trying to test it using karma, however I am having some problems when checking if the field is invalid, it seems it's always valid.
Here is my ...
1
vote
0
answers
39
views
Unit testing angular directive with link function
My link function of a directive
shows some dummy mock
ask for external data (promise).
Whenever the promise resolves or rejectes dummy data is hidden
Is there a way to unit test directive, checking ...
1
vote
1
answer
2k
views
Unit Testing Angular Attribute Directive
I am having some problems testing an AngularJS (1.5) Attribute restricted Directive. See the below example directive and following unit test, of which produces a broken unit test.
Directive
(...
2
votes
1
answer
586
views
Unit tests for Angular js directive for ui-mask
I have a directive called maskUI
.directive('uiMask', function () {
return {
template: '<input ui-mask="{{maskPattern}}"/>',
replace: true,
scope: true,
...
0
votes
1
answer
65
views
Testing angularjs directive for attribute
I have the following directive which works fine and now I need to unit test it,
(() => {
angular
.module('app.utilities')
.directive('allowPattern', allowPatternDirective);
function ...
0
votes
1
answer
61
views
unit testing directive and isolatedScope not a function
I am trying to unit test a directive that was previously written and for my first unit test all I want to do is check a variable inside the scope of the directive.
However, every time I try to run ...
0
votes
1
answer
598
views
How to write unit test for angularjs Attribute type directives in jasmine
I have some directives without using any template/templateUrl. How can i write a unit test for this directive. The below code is my directive.
var app = angular.module('SampleDirective');
app....
3
votes
1
answer
988
views
How do I test the HTML pointed to by the templateUrl of an angular directive?
I have a directive:
app/controllers/battle.js
angular.module('myModule')
.controller('myController',
['$scope',
function($scope){
$scope.sayHello = function(){console.log('hello');};
}])...
1
vote
0
answers
254
views
Testing linked function in angular directive doesn't work
I'm quite new to the unit-testing using jasmine and karma. I'm trying to test the function that's in the link in the directive. It's being called on the click event that I'm trying to get. Note that I'...
1
vote
1
answer
682
views
AngularJS unit test Directive's attribute value
I have a directive that looks like this:
<foo bar="5"></foo>
where bar is an attribute and not defined in the scope property of the DDO. How can I write a unit test to assert that the ...
1
vote
1
answer
1k
views
Unit Testing Custom File Input Directive
I am having a huge problem with getting a unit test to work for a custom file directive for angular 1.5.0 and Jasmine 2.4, I have looked at
How to provide mock files to change event of <input ...
0
votes
1
answer
63
views
unit testing of directive with default scope
I am trying to unit test a directive which has default scope(scope:false) but I am not able to inject dependency of its controller.
var MyApp = angular.module('MyApp',['MyDirectives','MyServices','...
3
votes
0
answers
5k
views
Jasmine cannot read property of undefined
I usually don't post the whole stack trace, but I've been having this problem with one individual unit test and it's driving me nuts. I've rewritten it at least 10 different times and 20 different ...
2
votes
1
answer
321
views
Angular unit testing initialize "nameless" controller in directive
I'm curious as to how I would go about unit testing what I think is an anonymous controller inside of a directive.
directive.js
app.directive('directive',
function() {
var controller = ['...