1

I'm using karma-ng-html2js-preprocessor.

The directory structure is like

-app
--directives
---gamelabel
----gamelabel.js
----gamelabel.html
-test
--gamelabel.test.js

karma.conf.js:

module.exports = function(config) {
  config.set({
    preprocessors: {
     'app/directives/gamelabel/gamelabel.html': ['ng-html2js']
    },
    ngHtml2JsPreprocessor: {
      stripPrefix: 'app/',
      moduleName: 'templates'
    },
    frameworks: ['jasmine'],

    files: [
      // BOWER
      [...bower components...] 

      // MOCK
      'test/mock/**/*.js',

      // SOURCES
      'app/app.js',
      'app/config.js',

      'app/**/*.mod.js',
      'app/common/config/config.pro.js',
      'app/directives/gamelabel/*.*',

      // TEST
      'test/*.test.js'
    ],
[...other stuff..]

  });
};

My Test file looks like this

describe('gamelabel', function() {
    var $compile;
    var $scope;
    beforeEach(module('GamelabelMod'));
    beforeEach(module('templates'));

    beforeEach(inject(function(_$compile_, _$rootScope_) {
        $compile = _$compile_;
        $rootScope_ = _$rootScope_.$new();      
    }));

    it('should create the title', inject(function($compile, $rootScope) {
        var elm = $compile('<game-label></game-label>')($rootScope);
        $rootScope.$digest();
        console.log(elm);
        expect(elm[0].outerHTML).toContain('div');
    }));
});

Now the Directive contains a templateUrl

templateUrl: 'directives/gamelabel/gamelabel.dir.html',

That is what i expect to find in "elm" inside the test. Instead i just see

'<game-label class="ng-scope"></game-label>' 

as compiled template.

What am i doing wrong?

UPDATE: I also tried to put the template inline inside the directive and is still the same so the problem is not with the template path.

Bolza
  • 1,904
  • 2
  • 17
  • 42

0 Answers0