If all of my templates are in my index.html
, with each inside its own <script type="text/ng-template" id="foo">...</script>
block, how can I get them into the $templatecache
so that Jasmine knows they exist?
Currently, Jasmine treats all of my templateUrl
values as if they were all remote paths. I have looked through karma-ng-html2js-preprocessor, but it appears that this is for getting discrete template files into $templatecache
, rather than script blocks.
Here is a plunker showing how the inline templates are loaded.
Use the
karma-ng-template-preprocessor
module:For example, set up karma.conf.js as follows:
Use it in your tests as such:
References
karma-ng-template-preprocessor
karma-ng-html2js-preprocessor