我不能让 karma-ng-html2js-preprocessor 为外部模板工作。
打包 Json 文件:
.....
"gulp-karma": "*",
"karma-coverage": "*",
"karma-jasmine": "*",
"karma-ng-html2js-preprocessor": "*",
"karma-phantomjs-launcher": "*",
.....
业力配置文件:
config.set({
browsers: [
....
],
frameworks: [
'jasmine'
],
plugins: [
'karma-jasmine',
'karma-phantomjs-launcher',
'karma-ng-html2js-preprocessor'
],
preprocessors: {
'app/**/*.html': 'ng-html2js'
},
ngHtml2JsPreprocessor: {
stripPrefix: 'app/'
}
});
文件在 Build 文件中定义并传递给 gulp-karma。以下是定义的文件:
config = { test: {
configFile: '.../karma.conf.js',
depends: [
.......
],
files: [
"app/**/*.js",
'app/**/*.html'
]
}
}
在我的指令规范中加载模板,如下所示:
beforeEach(module('app'));
beforeEach(module('app/tem/mytemp.html'));
我收到以下错误:
Error: [$injector:modulerr] Failed to instantiate module app/tem/mytemp.html due to:
Error: [$injector:nomod] Module 'app/tem/mytemp.html' is not available! You either misspelled the
在 karma debug.html html 文件被加载到链接标签输出中:
<script type="text/javascript" src="/absoluteC:.../app/tem/comp/mydirective.js"></script>
<link href="/absoluteC:..../app/tem/mytemp.html" rel="import">
<script type="text/javascript">
window.__karma__.loaded();
我错过了什么吗?如何调试并解决此问题?