how to use url parameters with karma-ng-html2js-preprocessor

187 Views Asked by At

Im trying to test out my directives, but when i load everything in with karma, and i use ng-html2js.

It loads the modules fine, and then it fails on

Error: Unexpected request: GET modules/contenteditable/contenteditable.html?v=1
No more request expected

Actual question

So how do i add url parameters to my ng-html2js modules?

Because we use ?v=VERSIONNUMBER to add caching to each template file, even the directive tempalates

Karma Config

preprocessors: {
  'common/modules/**/*.html': 'ng-html2js'
},

ngHtml2JsPreprocessor: {
    stripPrefix: 'common/',
    moduleName: function (htmlPath, originalPath) {
        return htmlPath;
    }
},

The test

describe("contenteditable", function() {
    var elm, $compile, $rootScope;

    beforeEach(function(){
        module(
            'angularModalService',
            'constant.phpConstants',
            'directive.contenteditable',
            'modules/contenteditable/contenteditable.html'
        );

        angular.mock.module('ngMockE2E');

        inject(function(_$compile_, _$rootScope_) {
            $compile = _$compile_;
            $rootScope = _$rootScope_;
        });

        elm = angular.element('<rte></rte>');

        scope = $rootScope;
        $compile(elm)(scope);
        scope.$digest();

    });

    it("should compile the widget", function() {

        console.log(elm[0]);
    });

});
0

There are 0 best solutions below