加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

angularjs – 似乎无法获得’karma-ng-html2js-preprocessor’的

发布时间:2020-12-17 18:03:48 所属栏目:安全 来源:网络整理
导读:继续给我这个错误:模块“模板”不可用!您要么错误拼写了模块名称,要么忘记加载它. 我在几个Angular项目中实现了Directives的单元测试,现在它似乎无法工作.这是我的karma.conf module.exports = function(config){config.set({ basePath : '../',files : [
继续给我这个错误:模块“模板”不可用!您要么错误拼写了模块名称,要么忘记加载它.

我在几个Angular项目中实现了Directives的单元测试,现在它似乎无法工作.这是我的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'
    }
});
};

我绝对100%肯定在给定位置有.html文件.我仔细检查了说明,它只是不加载:beforeEach(module(‘templates’));在spec文件中.

我在这里错过了什么吗?最可能 :-)

–edit:在’webapp / js / components / ** / * .html’路径中忘了’js’,仍然无法正常工作.

解决方法

错误消息

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-junit-reporter','karma-html2js-preprocessor'
        ],

而不是karma-ng-html2js-preprocessor

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

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读