angularjs - Karma compiling Angular directive in test -


hi trying compile angular directive within karma test so:

 describe("midway: testing app", function() {     var $compile, $rootscope;     beforeeach(module('kssapp'));     beforeeach(inject(         ['$compile','$rootscope', function($c, $r) {         $compile = $c;         $rootscope = $r;         }]     ));      it("should compile widget", function() {        var element = $c('<my-app></my-app>')($r);        console.log(element);     });  }); 

this adds ng-scope class element , not compile full directive.

you might need run digest loop, plus think have inverted injected , testing variables ($scompile , $rootscope):

describe("midway: testing app", function() {     var $compile, $rootscope;     beforeeach(module('kssapp'));     beforeeach(inject(         ['$compile','$rootscope', function($c, $r) {         $compile = $c;         $rootscope = $r;         }]     ));      it("should compile widget", function() {        // you're out of inject function used full variable names        var element = $compile('<my-app></my-app>')($rootscope);         // run digest loop        $rootscope.$digest();        console.log(element);     });  }); 

Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -