無数の重複した質問にリダイレクトされる前に。私がそれらをチェックして解決策を試したことをみんなに知ってもらいたいのですが、それは私にとってはうまくいきません。問題は私のパスにあると思いますが、プロジェクトのセットアップ方法では、何が問題なのかわかりません。だから私は私たちのプロジェクトをレイアウトし、うまくいけば誰かが私を助けることができます
コンポーネント プロセスを使用しており、プロジェクトは次のように構成されています。
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 */}