5

このエラーが表示され続けます: モジュール 'テンプレート' は利用できません! モジュール名のつづりを間違えたか、モジュールをロードするのを忘れました。

いくつかの Angular プロジェクトでディレクティブの単体テストを実装しましたが、今ではうまくいかないようです。ここに私の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'
    }
});
};

指定された場所に .html ファイルがあることは 100% 確実です。beforeEach(module('templates'));指示を再確認しましたが、スペックファイルで読み込まれません。

ここで何か不足していますか?おそらく :-)

--edit: パス 'webapp/js/components/**/*.html' の 'js' を忘れましたが、まだ機能しません。

4

1 に答える 1

0

エラーメッセージ

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.

プラグインに karma-html2js-preprocessor をインストールしてリストすることで再現可能です

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

karma-ng-html2js-preprocessor の代わりに

plugins : [
        'karma-chrome-launcher',
        'karma-firefox-launcher',
        'karma-jasmine',
        'karma-junit-reporter',
        'karma-ng-html2js-preprocessor'
        ],
于 2015-04-03T09:57:36.103 に答える