As of docs, expect.anything() matches anything but null or undefined. So, .not.toEqual(expect.anything()) will match null or undefined.
expect.anything()
null
undefined
.not.toEqual(expect.anything())