title: When does Jasmine .toHaveBeenCalledWith match the parameters?
body: <p>I have the following angular service and its jasmine test. The test calls f1() and spies on f2(). The function f2 takes variable v2 and modifies it (sets field a to 3). The function f2 should be called with v2 (as declared in f1) but my test fails on <strong>toHaveBeenCalledWith</strong> and says actual call was with the object as after the f2 function call. Does jasmine match the parameters for .toHaveBeenCalledWith after the function call, which shouldn't be the recommended way or am I making some mistake here.</p>
  
  <p><strong>Service:</strong></p>
  
  <pre><code>export class JasmineTestClass{
      constructor(){
      }
      f2(v2){
          v2.a = 3
      };
      f1(v1){
          let v2 = {
              a:30
          };
          this.f2(v2);
      }
  }
  </code></pre>
  
  <p><strong>Test:</strong></p>
  
  <pre><code>describe('Test', () =&gt; {
      let service: JasmineTestClass;
      beforeEach(() =&gt; {
          service = new JasmineTestClass();
          spyOn(service, 'f2').and.callThrough();
      });
      let v1 = {
          a:2, b:3
      };
      let v2 = {
          a:30
      };
      it('should succeed', () =&gt; {
          service.f1(v1);
          expect(service.f2).toHaveBeenCalledWith(v2);    //this is failing
      });
  })
  </code></pre>
  
  <p><strong>Log:</strong></p>
  
  <pre><code>Test should succeed FAILED
  
  Expected spy f2 to have been called with [Object ({a:30})] but actual calls were [Object ({a:3})]
  </code></pre>
  
  <p><strong>Please note that I did debug in Chrome while testing and the function f2() is called with v2 = {a:30}.</strong></p>