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.
This commit is contained in:
Nikita Tovstoles
2014-01-29 10:02:56 -08:00
committed by Brian Ford
parent 95bd046881
commit 8bc77b68b3
+6
View File
@@ -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.