I created unit (async) test in Jest. But when I get response from server:
[
{
name: "My name"
},
{
name: "Another name"
}
]
and test it:
test('Response from server', () => {
get('my-url').end(error, response) => {
expect(response.body).toBe(expect.any(Array))
}
})
some error occurs:
Comparing two different types of values. Expected Array but received array.
It's working when I use expect(response.body).any(Array). But is there any fix for expect.toBe()?
expect(response.body).any(Array)shouldn't work..anydoesn't exist on the response fromexpect()but onexpectitself. The referenced code gives this error: "TypeError: expect(...).any is not a function".