title: Jest unit testing arguments of each instance of function when called multiple times, but with slightly different outcomes
body: <p>I am calling a function that logs out, multiple times in one of my functions, and I am wanting to test the args passed each time it logs out.</p>
  
  <p>I did have this working, but have since changed how what it is passing slightly.</p>
  
  <p>Originally I was logging a string and then an object, ie.</p>
  
  <pre><code>myObject = {
    'one': 'one',
    'two': 'two'
  }
  
  myfunct() {
    log.info('some string', myObject);
    log.info('some other string', myObject);
  }
  </code></pre>
  
  <p>and I was testing with</p>
  
  <pre><code>// spying on logger
  ...
  expect(spyLog).toHaveBeenNthCalledWith(1, 'some string', myObject);
  expect(spyLog).toHaveBeenNthCalledWith(2, 'some other string', myObject);
  </code></pre>
  
  <p>I have now changed the object to actually incorporate the string that will be assigned directly, ie:</p>
  
  <pre><code>myNewObject(myString: string) {
    return {
      'string': myString,
      'one': 'one',
      'two': 'two'
    }
  }
  
  myfunct() {
    log.info(myNewObject('some string'));
    log.info(myNewObject('some other string'));
  }
  </code></pre>
  
  <p>Is there a way in which I can test the passed arguments without having to create consts of each differing object? </p>
  
  <p>ie. I am wanting to avoid a situation such as:</p>
  
  <pre><code>myFirstObject = {
    'string': 'some string',
    'one': 'one',
    'two': 'two'
  };
  
  mySecondObject = {
    'string': 'some other string',
    'one': 'one',
    'two': 'two'
  };
  
  expect(spyLog).toHaveBeenNthCalledWith(1, myFirstObject);
  expect(spyLog).toHaveBeenNthCalledWith(2, mySecondObject);
  </code></pre>
  
  <p>If I have more of these logs outputting, I do not wish to have mountains of consts defining almost identical information...</p>