title: AngularJS Jasmine Testing - $scope Variable State Not Saved at End of It Statement?
body: <p>I have the following function test in Jasmine:</p>
  
  <pre><code>describe("myFunction test", function(){
      it("should set $scope.variable to 'test'", function(){
           scope.myFunction("test");
           expect(scope.variable).toBe("test"); //This passes
           console.log(scope.variable); // This logs "test"
      });
      it("should set $scope.variable to null", function(){
           console.log(scope.variable); // Shouldn't this log "test" and not undefined?
           scope.myFunction("test");  
           expect(scope.variable).toBeNull();
      })
  });
  </code></pre>
  
  <p>My function in my controller looks like:</p>
  
  <pre><code>$scope.myFunction = function(param){
      if(param === $scope.variable){
          $scope.variable = null;
      }
      else{
          $scope.variable = param;
      }
  });
  </code></pre>
  
  <p>The function above takes the parameter passed in and compares it against <code>$scope.variable</code>.  If the two values match, <code>$scope.variable</code> is set to <code>null</code>.  Otherwise <code>$scope.variable</code> is changed to the parameter's value.  </p>
  
  <p>In my Jasmine test, I noticed that after <code>scope.variable</code> has been set in an <code>it</code> statement, the value isn't carried over to the next <code>it</code> statement.  Are <code>$scope</code> variables in a Jasmine test not saved every time the <code>it</code> statement it was called in comes to an end?</p>