Maybe the type of expectation variable and the answer on the right side are different in your case.
In my case, the error occurred because I tried to use toBe assertion in an array, and not in the array.length
Wrong example:
expect(array).toBe(3)
Correct example:
expect(array.length).toBe(3)