title: Testing arguments with toBeCalledWith() in Jest
body: <p>I have function that uses <code>puppetteer</code>'s <code>page</code> object to evaluate and return some data. </p>
  
  <p>I would like to write a unit test with <code>jest</code> to check if <code>page.evaluate()</code> takes specified parameters</p>
  
  <p>This is the function </p>
  
  <pre><code>async function cinemasfromState(page, state) {
    const CINEMA_SELECTOR = `div[data-state=$[STATE]] div.top-select-option a.eccheckbox`;
    let res = await page.evaluate(
      (elementPath, state) =&gt; {
        let results = Array.from(document.querySelectorAll(elementPath)).map(
          function(cin, index) {
            return {
              //Stuff
            };
            return result;
          },
          { state }
        );
      },
      CINEMA_SELECTOR.replace("$[STATE]", state),
      state
    );
  
    return res;
  }
  </code></pre>
  
  <p>Below is what my test looks like </p>
  
  <pre><code>describe("cinemasfromState", () =&gt; {
    let page_mock = {
      click: jest.fn(() =&gt; Promise.resolve()),
      evaluate: jest.fn((selector, state) =&gt; Promise.resolve())
    };
  
    test("page.evaluate called correctly ", async () =&gt; {
      await cinemasfromState(page_mock, "KAN");
      expect(page_mock.evaluate).toBeCalledTimes(1);
      expect(
        page_mock.evaluate)toBeCalledWith(
          "div[data-state=KAN] div.top-select-option a.eccheckbox",
          "KAN"
        );
    });
  });
  </code></pre>
  
  <p>And I get the below error as my test output</p>
  
  <pre><code>● cinemasfromState › page.evaluate called correctly
  
      expect(jest.fn()).toBeCalledWith(expected)
  
      Expected mock function to have been called with:
        "div[data-state=KAN] div.top-select-option a.eccheckbox"
      as argument 1, but it was called with
        [Function anonymous].
  
      Difference:
  
        Comparing two different types of values. Expected string but received function.
        "KAN"
      as argument 2, but it was called with
        "div[data-state=KAN] div.top-select-option a.eccheckbox".
        undefined
      as argument 3, but it was called with
        "KAN".
  
      Difference:
  
        Comparing two different types of values. Expected undefined but received string.
  
        52 |     expect(page_mock1.evaluate).toBeCalledTimes(1);
        53 |     expect(page_mock1.evaluate).toBeCalledWith(
      &gt; 54 |       "div[data-state=KAN] div.top-select-option a.eccheckbox",
           |                            ^
        55 |       "KAN"
        56 |     );
        57 |   });
  </code></pre>
  
  <p>Any help on writing test to verify the arguments?</p>