Skip to content Skip to sidebar Skip to footer

Karma-ng-html2js-preprocessor Not Creating Modules

Attempting to use the karma-ng-html2js-preprocessor. Karma has been finding all of my other stuff (javascript) fine, but when it comes to this html preprocessor it can't seem to fi

Solution 1:

I know this doesn't necessarily answer your question and if more information comes to light, I'll add to this answer but I've found this strategy works well...

I find that the HTML template of a directive, route or state (if using ui-router) shouldn't come into play when unit testing. Unit testing is about testing the interface to your component; its publicly available methods and properties. Testing the interactions with the HTML document is really in the realm of end-to-end testing with something like Protractor.

With that in mind, here's how I prevent Karma from attempting to load template files during testing.

beforeEach(function() {
    module('module.name.of.the.testable.component');

    inject(function($templateCache) {
        $templateCache.put('path/to/template/as/it/appears/in/your/component.html',
            '<div></div>');
    });
});

Post a Comment for "Karma-ng-html2js-preprocessor Not Creating Modules"