My test involving a mock function (React, Enzyme and Jest) works:
it('should do a thing', () => {
  const myButton = wrapper.find('Button');
  expect(mockFunction.mock.calls.length).toBe(0);
  myButton.simulate('click');
  expect(mockFunction.mock.calls.length).toBe(1);
});
However when I try to simplify the code with a variable the test fails. numberClicks is 0 both times.
it('should do a thing', () => {
  const myButton = wrapper.find('Button');
  const numberClicks = mockFunction.mock.calls.length;
  expect(numberClicks).toBe(0);
  myButton.simulate('click');
  expect(numberClicks).toBe(1);
});
Is this normal JavaScript behaviour or some weirdness with the testing libraries?
 
    