0

在我被重定向到无数重复的问题之前。我希望每个人都知道我已经检查过他们并尝试了他们的解决方案,但它对我不起作用。我认为问题出在我的路径上,但是我们的项目设置方式我似乎无法弄清楚出了什么问题。所以我会布置我们的项目,希望有人可以帮助我

我们正在使用组件流程,项目的结构如下:

src
   -app
      -components
       -some-component
        components.some-component.module.js
        some-component.html
        some-component.component.js
        some-component.component.spec.js           
config.js
gulpfile.js
karma.conf.js

业力.conf.js

var config = require('./config');
module.exports = function(karmaConfig){
 karmaConfig.set({
  files: [].concat(
    config.source.js.libraries,
    config.source.js.testLibraries,
    config.source.js.apps,
    config.source.js.tests,
    '**/*.html'  // this is me trying path stuff
  },
  frameworks: ['mocha','sinon-chai'],
  ....
  plugins: [
    'karma-firefox-launcher',
    'karma-mocha',
    'karma-sinon-chai',
    'karma-ng-html2js-preprocessor'
  ],
  preprocessor: {
    '**/*.html' : ['ng-html2js']
  },
  ngHtml2JsPreprocessor: {
    stripPrefix: 'src/app',
    moduleName: 'templates',
    cachedIdFromPath: function(filepath){
      console.log('File ' + filepath);
      return filepath;
  }
 });
}

config.js 文件很长。它是所有文件位置路径的中心位置。我将提供文件的一部分:

module.exports = {
  angular: {
    source: {
      js: {
        app: [
          'src/app/**/*.module.js',
          'src/app/**/*.js',
          '!src/app/**/*.spec.js'
        ]
      }
    }
  }
};

我得到的错误是Module 'templates' is not available。就像我说的那样,我尝试了各种解决方案,但似乎无法解决问题。任何帮助将不胜感激,如果需要,我会更详细地更新这个问题。

先感谢您。

编辑 规格文件。

describe('component: some-component', function(){
  beforeEach(module('app.components.some-component'));
  beforeEach(module('templates'));
  .....
});

some-component.component.js 文件:

angular
  .module('app.components.some-component')
  .component('someComponent', {
    templateUrl: 'components/some-component/some-component.html',
    ....
    }
  });
function Controller(){/* function code here */}
4

1 回答 1

0

我不知道是什么问题。我仍然假设这是一个路径的事情。我们实现了 Babel 和某人如何修复它。我真的不明白如何,但我将此问题标记为已解决。

于 2016-10-25T13:24:18.053 回答