I can't make karma-ng-html2js-preprocessor working for external template.
Package Json file:
.....
"gulp-karma": "*",
"karma-coverage": "*",
"karma-jasmine": "*",
"karma-ng-html2js-preprocessor": "*",
"karma-phantomjs-launcher": "*",
.....
Karma config file:
config.set({
browsers: [
....
],
frameworks: [
'jasmine'
],
plugins: [
'karma-jasmine',
'karma-phantomjs-launcher',
'karma-ng-html2js-preprocessor'
],
preprocessors: {
'app/**/*.html': 'ng-html2js'
},
ngHtml2JsPreprocessor: {
stripPrefix: 'app/'
}
});
Files are defined in Build file and passed to gulp-karma. Here are the defined files:
config = { test: {
configFile: '.../karma.conf.js',
depends: [
.......
],
files: [
"app/**/*.js",
'app/**/*.html'
]
}
}
Loading template in my directive spec like below:
beforeEach(module('app'));
beforeEach(module('app/tem/mytemp.html'));
I am getting the error below:
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
In karma debug.html html files are loaded in link tag output:
<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();
Am I missing anything? How do I debug and move forward from this issue?
I am new to this as well and I'm googling around for another problem but I think I'm a little further along than you are (I also realize this quest is a little old).
What I did was to make the following change to the ngHtml2JsPreprocessor section of the Karma config file
Then in my test I referenced that module name instead of the HTML name.
I hope that helps even if it's late. Or that someone else finds the information useful as they are searching around.