AngularJS アプリのカルマ テストを設定しようとしていますが、どういうわけか常に失敗しています。ここのすべての手順に従いましたが、ng-html2js プリプロセッサが正しく機能していないように感じます。私は常に次のメッセージを受け取ります:
エラー: 予期しない要求: GET js/templates/my-template.template.html
これが私のコード構造です
そしてここに私のテスト構造
私がテストしようとしているディレクティブは次のとおりです。
angular
.module('myapp')
.directive('myDirective', ['myService', function (myService) {
return {
restrict: 'E',
templateUrl: 'js/templates/my-template.template.html',
scope: {},
link: function (scope) {
}
}
}]);
私のカルマconfは次のようになります:
module.exports = function (config) {
config.set({
basePath: '../../',
frameworks: ['jasmine'],
files: [
//some omitted like angular and so on...
'main/resources/static/**/*.js',
'**/*.html',
'test/js/**/*Spec.js'
],
preprocessors: {
'**/*.html': ['ng-html2js']
},
ngHtml2JsPreprocessor: {
moduleName: 'templates'
}
... (more default stuff omitted)
}
および mySpec.js は次のようになります。
describe('directive', function () {
'use strict';
beforeEach(module('myapp'));
beforeEach(module('templates'));
var elm,
scope;
beforeEach(inject(function ($rootScope, $compile) {
elm = angular.element(
'<my-directive>' +
'</my-directive>');
scope = $rootScope.$new();
$compile(elm)(scope);
scope.$digest();
}));
describe('Does something', function () {
console.log('test');
expect(true).toBe(true);
});
});