无法实例化模块ng-html2js

时间:2018-06-13 02:33:06

标签: angularjs karma-jasmine ng-html2js

最近我安装了ng-html2js-preprocessor以便能够测试karma-jasmine中的组件,但是我遇到了1个问题。第一个来自这里:

12 06 2018 23:24:55.832:WARN [web-server]:404:/views/home.controller.html

我认为业力无法正确找到我的html文件而第二个是Phantomjs的错误:无法找到变量:require"

这是我的代码:

describe('Testando o includeReplace - Directive', function() {
    var scope, template, httpBackend, isolateScope;

    beforeEach(module('DS-APP'));
    beforeEach(module('ngTemplates'));

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

        var element = angular.element('ELEMENTO');

        template = $compile(element)(scope);
            scope.$digest();

            isolateScope = element.isolateScope();
    }));

    afterEach(function() {
        httpBackend.verifyNoOutstandingExpectation();

        httpBackend.verifyNoOutstandingRequest();
    });

    it('devera gerar o HTML corretamente', function() {

        var templateAsHtml = template.html();
    });
});

这是我的karma.conf.js:

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

    basePath: '',

    frameworks: ['jasmine'],

    files: [
    'node_modules/jquery/dist/jquery.min.js',
    'node_modules/angular/angular.js',
    'node_modules/karma-ng-html2js-preprocessor/lib/html2js.js',
    'node_modules/angular-sanitize/angular-sanitize.min.js',
    'node_modules/angular-mocks/angular-mocks.js',
    'node_modules/angular-animate/angular-animate.min.js',
    'node_modules/angular-resource/angular-resource.js',
    'node_modules/angular-sanitize/angular-sanitize.js',
    'node_modules/moment/min/moment.min.js',
    'node_modules/moment/locale/de.js',
    'node_modules/angular-moment/angular-moment.min.js',
    'node_modules/@uirouter/angularjs/release/angular-ui-router.min.js',

    'app/index.ng.js',
    'app/**/**.js',
    'app/**/**.spec.js',
    'app/**/*.html'
    ],

    plugins: [
    'karma-jasmine',
    'karma-spec-reporter',
    'karma-phantomjs-launcher',
    'karma-ng-html2js-preprocessor'
    ],

    exclude: [
    ],

    preprocessors: {
        'app/**/*.html': ['ng-html2js']
    },

    ngHtml2JsPreprocessor : {
      stripPrefix: 'app/',
      prependPrefix: '/views/',
      moduleName :  'ngTemplates'
   },

   reporters: ['spec'],

   port: 9876,

   colors: true,

   logLevel: config.LOG_INFO,

   autoWatch: true,

   browsers: ['PhantomJS'],

   singleRun: false,

   concurrency: Infinity
});
}

我的文件组织的图片

my main folder

inside folders components, etc has html to work

in build I serve my app

0 个答案:

没有答案