Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit 273e34e

Browse files
dukehoopsbtford
authored andcommitted
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.
1 parent 98d5885 commit 273e34e

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

docs/content/guide/unit-testing.ngdoc

+6
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,12 @@ We inject the $compile service and $rootScope before each jasmine test. The $com
337337
to render the aGreatEye directive. After rendering the directive we ensure that the directive has
338338
replaced the content and "lidless, wreathed in flame, 2 times" is present.
339339

340+
### Testing Directives With External Templates
341+
342+
If your directive uses `templateUrl`, consider using
343+
{@link https://github.com/karma-runner/karma-ng-html2js-preprocessor karma-ng-html2js-preprocessor}
344+
to pre-compile HTML templates and thus avoid having to load them over HTTP during test execution.
345+
Otherwise you may run into issues if the test directory hierarchy differs from the application's.
340346

341347
## Sample project
342348
See the [angular-seed](https://github.com/angular/angular-seed) project for an example.

0 commit comments

Comments
 (0)