私はAngularJSアプリのカルマテストを設定しようとしていますが、何とか失敗しています。 私はすべてのステップhereを実行しましたが、ng-html2jsプリプロセッサが正しく動作していないと感じました。私はいつも、次のメッセージを取得しています:AngularJSカルマテスト:予期しないリクエスト:GET.template.html
Error: Unexpected request: 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);
});
});
これを回避するためにng-html2jsは存在しないのですか?つまり、私の指示htmlはかなり大きいかもしれませんし、そこに貼り付けたくないのです。 – user3083022
ng-html2jsによって生成されるファイルはどのフォルダですか? –
それは私が自分自身に尋ねてきたことです。どうすればそれを見つけることができますか?ところで、 – user3083022