0
votes
1answer
57 views

how to unit-test setInterval in karma angularjs

app.directive('shuffleBlocks', function($timeout){ return { link: function(sco,ele,att){ if (itemCnt <= 1) return; /*Trigger fuction*/ function ...
0
votes
1answer
132 views

Karma testing a directive says angular.element has no method 'hide'

I'm trying to setup Karma to test an angular app that I'm building. I've already setup testing around my services and controllers but am finding directives somewhat more complicated to test. The ...
2
votes
2answers
115 views

unit test spy on $emit

I'm trying to spy on an $emit from a directive, but somehow I cannot get the spy to 'hear' the $emit. This is the code in my directives' controller: $scope.$on('send', function () { ...
0
votes
1answer
107 views

Unit testing an angular directive wrapping slickgrid

I would like to test my angular directive that is a wrapper around slickgrid. 'use strict'; describe('Unit: Grid Directive', function() { var $scope; var element; beforeEach(module('grid')); ...
1
vote
0answers
85 views

cannot use $rootScope.$new() in testing directive

I have a unit test for my directive: describe('Directive: ov-tabs', function() { var $compile, scope,subScope, element, template, doc,timeout,window; ...
0
votes
0answers
34 views

ngAnimate interferes with unit tests concerning ngClass in v1.2.0-rc.2 and an aside

I have some unit tests for a directive that worked fine until I migrated to the latest release candidate. The tests pass without incident even under the RC, but fail if the main module includes ...
0
votes
1answer
125 views

Unit testing a directive with <select>

I have a directive called <dimension> that renders html: angular.module('myApp.directives'). directive('dimension', ['$rootScope', 'Dimension', function($rootScope, Dimension) { return { ...
1
vote
1answer
97 views

How to test directive which template have ng-include inside the ng-repeat

I write a directive. In the template i have used ng-include inside the ng-repeat: <div ng-repeat="page in wStepPages" id="step{{$index}}" data-ng-show="getCurrentStep() == $index" ...
0
votes
1answer
119 views

BeforeEach with expectGets cannot be executed more then once

I have a problem with my unit test for a directive where I need to setup the directive before being able to test it. This is the way I initialize it: var elm, $templateCache var count = 0; ...
0
votes
1answer
27 views

Testing angularj facebook login directive

I am creating a Facebook login directive based off this blog. app.directive('facebook', function($http) { return { restrict: 'A', scope: true, controller: function($scope, ...
0
votes
1answer
300 views

Angular.js Unit/Integration Testing - Trigger Link Function

Currently, I am writing a test (using Jasmine) for a directive, and I suspect the link function is not being triggered. The directive is as follows: .directive('userWrapperUsername', [ ...
0
votes
2answers
374 views

Unit test angular right-click directive

I want to write a Jasmine unit test for an AngularJS directive. The directive simply binds a contextmenu event handler function to the element: var myDirectives = angular.module('myApp.directives', ...
0
votes
1answer
458 views

How can I simulate blur when testing directives in angularjs?

The problem I am trying to test some directives (code for both below). One of them is an "email" (called "epost" in the code(norwegian)) directive. The solution to this should work for all of them, ...
1
vote
1answer
461 views

AngularJS: how to invoke event handlers and detect bindings in tests

I want to write unit and e2e tests for various custom angularjs directives that add javascript event bindings to the elements they are attached to. In tests, it's easy enough to simulate click and ...
4
votes
2answers
335 views

How do you mock directives to enable unit testing of higher level directive?

In our app we have several layers of nested directives. I'm trying to write some unit tests for the top level directives. I've mocked in stuff that the directive itself needs, but now I'm running into ...
6
votes
2answers
2k views

How to Unit Test Isolated Scope Directive in AngularJS

What is a good way to unit test isolated scope in AngularJS JSFiddle showing unit test Directive snippet scope: {name: '=myGreet'}, link: function (scope, element, attrs) { //show ...
2
votes
0answers
329 views

Get validity in Unit test of Angular JS directive

I'm unit testing my directive and doing it like this: describe("myDate", function() { var $compile, $rootScope; var validDate, invalidDate, invalidDateFormat, element; ...
3
votes
1answer
282 views

Effectively unit test an AngularJS directive which is manipulating the DOM

I am working on a simple directive with AngularJS to add a smooth scrolling effect to any link. I have published my work here: https://github.com/arnaudbreton/angular-smoothscroll Everything works in ...
3
votes
1answer
157 views

Unit test directive inside a directive

I'm having troubles unit testing a directive that wraps the ng-grid component. I've written this punkler that shows the issue : http://plnkr.co/edit/HlB8Bt9M2TzsyM6XaDso?p=preview There is a lot of ...
5
votes
2answers
615 views

What is the best approach to use Disqus in a single page application?

What is the best approach to use Disqus in a single page application? I see that the angular js docs has implemented it successfully. Currently our approach looks like is this in our AngularJS app, ...
5
votes
2answers
2k views

How to inject a service in a directive unit test in AngularJS

I need to test a directive that does some calls to some injected services. The following piece of code is an example directive, that listens for events, and redirects the browser if enter is pressed ...
2
votes
1answer
495 views

How to test if exception is thrown in AngularJS

I need to test a directive, and it should throw an exception. How can I test that the exception was thrown, in jasmine? The implementations link function: link: function _linkFn(scope, element, ...
11
votes
1answer
2k views

Unit-testing directive controllers in Angular without making controller globally accessible and rewritable

In Vojta Jinas excellent repository where he demonstrates testing of directives, he defines the directive controller outside of the module wrapper. See here: ...
7
votes
1answer
3k views

What is the best approach to test events in angular?

How can i test for events in angular js? I need to test the following code, but I have little experience testing. I figured i need to use spies in some way to see if events have fired or something, ...
11
votes
1answer
2k views

To test a custom validation angular directive

This custom validation directive is an example presented at the official angular site. http://docs.angularjs.org/guide/forms It checks a text input is in number format or not. var INTEGER_REGEXP = ...
5
votes
2answers
533 views

Testing directives that uses templates

How can i unit test directives that use templateUrl to load templates? Since $httpBackend is a mock, it will not load templates either. I would like to be able to use something like ...
5
votes
4answers
3k views

Jasmine tests AngularJS Directives with templateUrl

I'm writing directive tests for AngularJS with Jasmine, and using templateUrl with them: https://gist.github.com/tanepiper/62bd10125e8408def5cc However, when I run the test I get the error included ...
7
votes
2answers
1k views

scope.$watch not called in directive when unit testing

Problem I am testing a directive. The directive has a watch on a scope variable, but the watch is never called. Putting the $watch call directly inside the unit test works. Why isn't the $watch in ...