I'm a bit of a newbie to Jest so please forgive me if this is an obvious answer but I cannot find an answer after scrolling through the docs.
I have a function (funcA) which passes an array of different lengths to another function (funcB) dependent on the arguments that funcA receives. I'm attempting to test the the length of the array that is passed to funcB is correct based on the arguments that I give to funcA. I am not that bothered about the contents of the array, just that it has a certain length. This is my current attempt:
// Modules
const funcA = require('./funcA')
// Mock
const funcB = jest.fn(pairs => {
return pairs[0]
})
// Test
test('Should pass array of 3623 length', () => {
const result = funcA(75)
expect(result).toBeInstanceOf(Object)
expect(funcB).toHaveBeenCalledWith(expect.any(Array).toHaveLength(3623))
})
I wanted to try to use any() if I could but the following test results in the error:
TypeError: expect.any(...).toHaveLength is not a function
I get the same error even if I wrap the expect.any(...) in another set of parentheses. Is there any way to achieve what I want?