mercredi 2 décembre 2015

AngularJS + Karma + Symfony : How to unit test directives when template is http-loaded from a twig template

I am wondering what is the cleanest way to unit test AngularJS directives for which templateUrl refers to a Twig template returned by Symfony, for exemple:

directives.directive("myDirective", [function(){
    return{
        restriction: "E",
        templateUrl: 'http://server/symfony/templates/mytemplate'
    }
}]);

The problem is that $httpBackend is mocked by AngularJS Mock, so no http request is really sent, This problem is resolved using ngHtml2JsPreprocessor that will let link to real files without doing http requests.

But in my case, I have to do a true http request since the template is generated by Symfony, I cannot link to files directly.

Any idea? Thanks!

Aucun commentaire:

Enregistrer un commentaire