mercredi 4 octobre 2017

Can`t access directive scope Karma

I search for this problem,and I`ve found a lot of answers but it didnt help me:( All seems to be okay but test fails. Error is undefined $scope.test.

Directive:

    app.directive("testBlock", function () {
    return {
        templateUrl: "templates/testBlock.html"
        , controller: function ($scope) {
            $scope.test = false;
      }
    };
});

Test:

     describe("Directive", function () {
     var $scope;
     beforeEach(inject(function ($rootScope, $compile) {
         $scope = $rootScope.$new();
         var element = angular.element("<test-block></test-block>");
         template = $compile(element)($scope);
         $scope.$digest();
         controller = element.controller;
     }));
     it("testing", inject(function () {

         expect($scope.test).toBeDefined();
     }));
 });

Aucun commentaire:

Enregistrer un commentaire