there are a lot of questions about the ng-html2js plugin but unfortunately all answers didn't help me to solve y issue.
I followed the official installation guide and the example https://github.com/vojtajina/ng-directive-testing/blob/master/test/tabsSpec.js.
My goal is to test a directive that has a templateUrl property, this is my config
karma.conf.js
files: [ ... // lots of studd here 'app/views/**/*.html' // templates are all here ], [...] // other karma configs here preprocessors: { 'app/views/**/*.html': ['ng-html2js'] },
The directive I would like to test it is really basic
'use strict'; angular.module('myAwesomeApp').directive('rzMenu', function () { return { templateUrl: 'views/directives/rzmenu.html', restrict: 'E' }; });
The unit test file for this
'use strict'; describe('Directive: rzmenu', function () { // load the directive's module beforeEach(module('myAwesomeApp')); beforeEach(module('app/views/directives/rzmenu.html')); var element, scope; beforeEach(inject(function ($rootScope, $compile) { element = angular.element('<rzmenu></rzmenu>'); scope = $rootScope.$new(); element = $compile(element)(scope); scope.$digest(); })); it('should have content', inject(function () { //scope.$digest(); var content = element.text(); expect(content).toBe(''); })); });
Look at the 'should have content' test, shouldn't be the content the same as the template?
Why I get and empty string?
Thanks in advance