0
votes
0answers
40 views

Test directive with AngularJs and Jasmine does not recognize directive element

I am trying to test a directive : App.directive('userAutocomplete', (selectedDate, $compile, $timeout) -> return { restrict: 'A' scope: { application: '=' } link : (scope, element, ...
0
votes
2answers
89 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
110 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, ...
0
votes
1answer
129 views

Can't test multiple instances of a angularjs directive in Jasmine running Karma

I have an uber-edge case here. I am writing a wrapper directive around a jQuery plugin that transforms a simple html element into a formal Feedback oriented view. <div ...
3
votes
2answers
427 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 ...
0
votes
1answer
146 views

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

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 that has different states. So ...
0
votes
0answers
90 views

Jasmine-jquery, testing generated GUI for (nested) directives

I recently started using jasmine-jquery (1.3.1) together with angular (1.0.6) and need an advice on testing GUI. I have some view for controller, which has angular directives, like 'view.html': ...
0
votes
1answer
139 views

Why isn't $digest updating my scope in my unit test

I have the following code. For some reason test 1 is failing. Can anyone tell me why? angular. module('myModule', []). directive('myDirective', function () { return { ...
0
votes
1answer
244 views

How should I access an element's angularjs $ngModelController in a jasmine unit test?

I'm currently using directiveElement.data("$ngModelController") to get access to the element's $ngModelController, as in the following example. describe("directiveElement", function () { it("should ...
5
votes
2answers
986 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
289 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, ...
10
votes
1answer
1k 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: ...
6
votes
1answer
1k 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, ...
2
votes
4answers
2k 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 ...