2014-11-14 90 views
0

嘗試使用generator-cg-angular。測試我的指令我得到「錯誤:意外的請求:GET生態系統/工作/指令/ configKey/configKey.html」我可以使用html2js修復,但根據cgross我不應該需要。他說我只是沒有正確配置httpBackend來傳遞模板請求。無法弄清楚我做錯了什麼。意外請求:GET使用grunt-angular-templates

此處瞭解詳情: https://github.com/cgross/generator-cg-angular/issues/78

代碼:

describe('Directive: configKey', function() { 
    beforeEach(module('app')); 

    var scope, ctrl, new_key; 

    beforeEach(inject(function ($rootScope, $controller) { 
     scope = $rootScope.$new(); 
     ctrl = $controller('ConfigKeyCtrl', { 
      $scope:scope 
     }); 
     new_key = { edit:true }; 
     scope.data = angular.copy(data); 
    })); 

    it('should highlight added keys', function() { 
     scope.key.change = 'add'; 
     scope.saveKey(); 
     scope.$digest(); 
     expect(elem.hasClass('alert-success')).toBe(true); 
    }); 
}); 

回答

0

我的問題是在卡拉姆的配置。 ngtemplate的輸出文件未包含在Karma的文件列表中。簡單地將'<%= ngtemplates.main.dest%>'添加到karam:選項:文件

files:    [ 
    '<%= dom_munger.data.appjs %>', 
    '<%= ngtemplates.main.dest %>', // Added this one 
    'bower_components/angular-mocks/angular-mocks.js', 
    'directive/**/*.html', 
    createFolderGlobs(['*-spec.js']) 
],