0

我一直在浏览有关此问题的许多问题,但我仍然没有弄清楚。(vojtajina/ng-directive-testing 也没有多大帮助)。

业力.conf.js

 preprocessors: {
             'app/components/partials/*.html': 'ng-html2js'
            },
ngHtml2JsPreprocessor: {
            stripPrefix: 'app/',
            moduleName:'flickrNgSpaApp'
           },
files: [      
      'app/**/*.js',
      'app/components/**/*.js',
      'test/mock/**/*.js',
      'test/spec/**/*.js',
      'app/components/partials/*.html'],

plugins: [
         'karma-ng-html2js-preprocessor'
        ],

templateUrl: 'components/partials/thumbnails.html',

和我的测试

describe('Directive: thumbnailsDirective', function () {
var $compile, $rootScope, template;
  beforeEach(module('flickrNgSpaApp', 'components/partials/thumbnails.html'));

beforeEach(inject(function(_$rootScope_, _$compile_, $templateCache)
  template=$templateCache.get();
  $templateCache.put());

...

错误:[$injector:modulerr] 无法实例化模块组件/partials/thumbnails.html..

任何人请!我做错了什么?

4

1 回答 1

0

您不必编写模板文件名,如下所示:

beforeEach(module('flickrNgSpaApp'));

您的所有模板文件都已包含在 fake moduleflickrNgSpaApp中。它与您的错误消息一致,因为模板文件不是模块。

于 2015-08-20T16:14:58.787 回答