In your case, you can test the controller of elements by accessing the functions of the controllers from the area of ββcompiled elements.
The easiest way to access the scope of an element is to call the #scope () function on the compiled angular element .
it ('should have a function X on scope', inject(function($rootScope, $compile) { var element = $compile('<div test-directive></div>')($rootScope); expect(element.scope().myFunction).toEqual(jasmine.any(Function)); });
Here is a simple example of the following method that is used in jsFiddle .
source share