lundi 22 février 2016

How to transfer values in Jasmine nested describe

I am using a describe inside a describe in Jasmine Karma test case. I see my variable value set in top describe is not getting transferred to nested level 1 describe. I was expecting this to work. How do I transfer values from one describe to its nested ?

describe('register.html page', function () {

    beforeEach(mockAnyApiCall);

    var $scope;
    var form;
    var createController;

    beforeEach(inject(function ($injector) {

        $scope = $injector.get('$rootScope').$new();
        var locals = {
            '$scope': $scope
        };
        createController = function () {
            $injector.get('$controller')('RegisterController', locals);
        };

        createController();

        var $templateCache = $injector.get('$templateCache');
        var templateHtml = $templateCache.get('scripts/app/account/register/register.html')
        var formElem = angular.element("<div>" + templateHtml + "</div>")
        var $compile = $injector.get('$compile');
        $compile(formElem)($scope);
        form = $scope.form;

        $scope.$apply()

        console.log("beforeEach: " + form);
    }));

    fdescribe('validation tests', function (){

        console.log('validator tests - '+ form);

        var fieldValidator = new FieldValidator();
        form.inputFirstName.$setViewValue('me');

Throws error saying form is undefined. How do I get this to work ?

Aucun commentaire:

Enregistrer un commentaire