Testing Directives that Use External Templates

The AngularJS folks kind of punt on this one a bit. Their suggestion, if you use a custom AngularJS directive that uses external templates via the templateUrl parameter, is to use something like karma-ng-html2js-preprocessor to precompile HTML templates and thus avoid having to load them over HTTP during tests.

You can get karma-ng-html2js-preprocessor here:

https://github.com/karma-runner/karma-ng-html2js-preprocessor

Get Learning AngularJS now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.