My karma.conf.js includes:
plugins: [
'karma-jasmine',
'karma-phantomjs-launcher',
'karma-ng-html2js-preprocessor'
],
preprocessors: {
'../../mypath/*.html': ['ng-html2js']
},
ngHtml2JsPreprocessor: {
moduleName: 'templates'
},
(I've tried without specifying any plugins, too.)
My devDependencies include:
"karma-ng-html2js-preprocessor": "^0.2.0"`
My tests include:
beforeEach(module('templates'));
These give the error:
Module 'templates' is not available!
Running karma with --log-level debug, I do not see any [preprocessor.html2js] entries. (I do get Loading plugin karma-ng-html2js-preprocessor.)
What am I doing wrong?
The issues were that the templates must be listed under
filesas well, and that the glob pattern inpreprocessorsmust match. This is implied by the documentation.Note that
**/*.htmldoes not match parent directories of thebasePath.karma start --log-level debugwill displayDEBUG [preprocessor.html2js]entries when everything is correct.I was also able to remove the
pluginssection.To get the correct cache ID, I used:
If a template references a custom filter, the filter must be loaded in
filesand the filter's module must be loaded in your directive tests.