Skip to content

Commit

Permalink
docs(guide/unit-testing): recommend pre-compiling templates
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
dukehoops authored and btford committed Mar 26, 2014
1 parent 98d5885 commit 273e34e
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions docs/content/guide/unit-testing.ngdoc
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 273e34e

Please sign in to comment.