mercredi 6 juillet 2016

Testing in jasmine- returns error of TypeError: undefined is not an object

I am new to writing test units and am receiving the following error when trying to execute my test:

TypeError: undefined is not an object  (evaluating '$scope.createRoleForm.canCreateAccount=false')

The function I want test is:

function enableAccountRoles() {
    $scope.createRoleForm.canCreateAccount = false;
    $scope.createRoleForm.canListAccounts = false;
    $scope.createRoleForm.canSearchAllChat = false;
    $scope.createRoleForm.canManageSite = false;
  }

and my test code is

 it('should call enableAccountRoles', function() {
    this.scope.enableAccountRoles();
  })

I know that this isn't complete as I have no expectation- do I need to set the value of the variables in the test file before running the test unit?

Aucun commentaire:

Enregistrer un commentaire