From 8bc77b68b315eb7332bbc1b1e8055b7e26a69779 Mon Sep 17 00:00:00 2001 From: Nikita Tovstoles Date: Wed, 29 Jan 2014 10:02:56 -0800 Subject: [PATCH] docs(guide/unit-testing): recommend pre-compiling templates quite a few folks struggle with how to test directives with external templates. karma-ng-html2js-preprocessor provides an easy solution but the issues is not raised in the docs. --- docs/content/guide/unit-testing.ngdoc | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/docs/content/guide/unit-testing.ngdoc b/docs/content/guide/unit-testing.ngdoc index f4a608d89..3d79ca915 100644 --- a/docs/content/guide/unit-testing.ngdoc +++ b/docs/content/guide/unit-testing.ngdoc @@ -337,6 +337,12 @@ We inject the $compile service and $rootScope before each jasmine test. The $com to render the aGreatEye directive. After rendering the directive we ensure that the directive has replaced the content and "lidless, wreathed in flame, 2 times" is present. +### Testing Directives With External Templates + +If your directive uses `templateUrl`, consider using +{@link https://github.com/karma-runner/karma-ng-html2js-preprocessor karma-ng-html2js-preprocessor} +to pre-compile HTML templates and thus avoid having to load them over HTTP during test execution. +Otherwise you may run into issues if the test directory hierarchy differs from the application's. ## Sample project See the [angular-seed](https://github.com/angular/angular-seed) project for an example.