ディレクティブで単体テストを実行しようとすると、このエラーが発生し続けます。
Error: Unexpected request: GET /assets/partials/project-brand.html
No more request expected
この問題を引き起こしている可能性のあるものに困惑しています。
ここに私のkarma.conf.jsがあります:
files: [
'js/*.js',
'partials/*.html',
'../tests/client/unit/*.js'
]
preprocessors: {
'partials/*.html': ['ng-html2js']
},
ngHtml2JsPreprocessor: {
stripPrefix: 'public/'
}
私のファイル編成:
-public
--js
---directives.js
--partials
---project-brand.html
-tests
--client
---unit
----directives.js
私の指示:
.directive('projectBrand', [function() {
return {
restrict: 'E',
scope: {
brand: '=',
projectId: '=',
index: '='
},
templateUrl: '/assets/partials/project-brand.html',
controller: ['$scope', function($scope){
$scope.isWorking = false;
}]}}])
最後に、ディレクティブ テスト ファイル:
beforeEach(module('app'));
beforeEach(module('partials/project-brand.html'));
beforeEach(inject(function(_$compile_, _$rootScope_){
$compile = _$compile_;
$rootScope = _$rootScope_;
$scope = $rootScope.$new();
$scope.brand = {id: 1};
$scope.project.id = 1;
$scope.index = 0;
element = angular.element('<project-brand brand="brand" project-id="project.id" index="$index"></project-brand>');
directive = $compile(element)($scope);
$scope.$apply();
}));
誰かが何か提案があれば、私は本当に感謝しています!