I often see my teammates use toHaveBeenCalledTimes in their tests with Jest to count how many times the dispatch method of Redux store was called.
It seems useless and redundant for me: if we check that the proper actions were called, why do we need to count the number of calls for the dispatch method?
Looks like this:
expect(setEnabled).toHaveBeenCalled();
expect(updateUserData).toHaveBeenCalled();
expect(dispatch).toHaveBeenCalledTimes(2);
Does it really make sense to check the number of calls for dispatch method? Looks like that in such case we don't really test that the function works as appropriate, but test the implementation.