简体   繁体   中英

Unexpected Request: GET using grunt-angular-templates

Trying to use generator-cg-angular. Testing my directives I get "Error: Unexpected request: GET ecosystem/job/directive/configKey/configKey.html" Which I can fix using html2js, but according to cgross I shouldn't need to. He says I just don't have httpBackend configured properly to pass through requests for templates. Can't figure out what I'm doing wrong.

More info here: https://github.com/cgross/generator-cg-angular/issues/78

Code:

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);
    });
});

My problem was in Karam's configuration. ngtemplate's out file was not being included in Karma's file list. Simply add '<%= ngtemplates.main.dest %>' to karam:options:files

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM