Podczas uruchamiania grunt karma
test jednej z dyrektyw kończy się niepowodzeniem podczas próby pobrania szablonu. Używam ng-html2js jako preprocesora. Oto niektóre z moich karma.conf.js"Błąd: nieoczekiwany wniosek" podczas testu jednostki kątowej Karma
plugins: ['karma-chrome-launcher',
'karma-jasmine',
'ng-html2js',
'karma-ng-html2js-preprocessor'],
preprocessors: {
'app/scripts/directives/**/*.html': 'ng-html2js'
},
ngHtml2JsPreprocessor: {
moduleName: 'templates'
}
W moim testu mam następujące:
'use strict';
describe('Directive: myDirective', function() {
// load the directive's module
beforeEach(module('myApp'));
beforeEach(module('templates'));
var element,
scope;
beforeEach(inject(function ($rootScope) {
scope = $rootScope.$new();
}));
it('should not show search area initially', inject(function ($compile) {
element = angular.element('<navbar></navbar>');
element = $compile(element)(scope);
scope.$digest();
expect(element.find('.myClass').hasClass('myClass')).toBe(true);
}));
});
Kiedy wykonać test, mam
Error: Unexpected request: GET /scripts/directives/myDirective/myDirective.html
Wygląda na to, że preprocesor nie wstrzykuje poprawnie wersji javascript szablonu.
Próbowałem również przy użyciu ścieżki szablonu w beforeEach(module(''));
ale powoduje błąd, który brzmi:
Error: [$injector:modulerr] Failed to instantiate module...
Jak mogę rozwiązać ten problem?