Cant seem to get 'karma-ng-html2js-preprocessor'doing its work

1k Views Asked by At

Keeps on giving me this error: Module 'templates' is not available! You either misspelled the module name or forgot to load it.

I implementend unit testing of Directives in several Angular projects and now it just wont seem to work. Here is my karma.conf

module.exports = function(config){
config.set({

    basePath : '../',

    files : [
        'webapp/lib/bower_components/angular/angular.js',
        'webapp/lib/bower_components/angular-route/angular-route.js',
        'webapp/lib/bower_components/angular-resource/angular-resource.js',
        'webapp/lib/bower_components/angular-animate/angular-animate.js',
        'webapp/lib/bower_components/angular-mocks/angular-mocks.js',
        'webapp/lib/bower_components/jquery/jquery.js',
        'webapp/lib/jasmine-jquery.js',
        'webapp/js/components/**/*.html',
        'webapp/app.js',
        'webapp/js/**/*.js',
        'test/unit/**/*.js',
        { pattern: 'webapp/stubs/*', watched: true, served: true, included: false }
    ],

    preprocessors: {
        'webapp/js/components/**/*.html': ['ng-html2js']
        //'webapp/components/**/.js' : ['coverage']
    },

    autoWatch : true,

    frameworks: ['jasmine'],

    browsers : ['Chrome'],

    plugins : [
        'karma-chrome-launcher',
        'karma-firefox-launcher',
        'karma-jasmine',
        'karma-ng-html2js-preprocessor'
    ],

    junitReporter : {
        outputFile: 'test_out/unit.xml',
        suite: 'unit'
    },

    ngHtm2JsPreprocessor: {
        moduleName: 'templates'
    }
});
};

I am absolutely 100% sure there .html files at the given location. I double checked the instructions and it just wont load: beforeEach(module('templates')); in the spec file.

Am I missing something here? Most probably :-)

--edit: forgot 'js' in the path 'webapp/js/components/**/*.html', still doesnt work.

1

There are 1 best solutions below

0
On

The error message

Error: [$injector:modulerr] Failed to instantiate module templates due to:
Error: [$injector:nomod] Module 'templates' is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the dependencies as the second argument.

is reproducible by installing and listing karma-html2js-preprocessor in your plugins

plugins : [
        'karma-chrome-launcher',
        'karma-firefox-launcher',
        'karma-jasmine',
        'karma-junit-reporter',
        'karma-html2js-preprocessor'
        ],

instead of karma-ng-html2js-preprocessor

plugins : [
        'karma-chrome-launcher',
        'karma-firefox-launcher',
        'karma-jasmine',
        'karma-junit-reporter',
        'karma-ng-html2js-preprocessor'
        ],